organizer.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <el-card shadow="never" class="aui-card--fill">
  3. <div class="mod-home">
  4. <div class="page-title">{{ pageTitle }}</div>
  5. <div class="btns adf">
  6. <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增举办方</el-button>
  7. </div>
  8. <el-table :data="dataList" border cell-class-name="vertical-top-cell" v-loading="loading" empty-text="暂无举办方" style="margin-top: 16px;">
  9. <el-table-column prop="channelName" label="举办方名称"></el-table-column>
  10. <el-table-column prop="contactName" label="联系人"></el-table-column>
  11. <el-table-column prop="contactPhone" label="联系方式"></el-table-column>
  12. <el-table-column label="操作">
  13. <template slot-scope="scope">
  14. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  15. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  16. </template>
  17. </el-table-column>
  18. </el-table>
  19. </div>
  20. <el-dialog width="700px" :visible.sync="show" :title="title" @close="cancel">
  21. <el-form ref="formRef" :model="form" :rules="rules" label-width="110px" style="width: 80%;margin: 0 auto;">
  22. <el-form-item label="举办方名称" prop="channelName">
  23. <el-input v-model="form.channelName" placeholder="请输入举办方名称"></el-input>
  24. </el-form-item>
  25. <el-form-item label="联系人" prop="contactName">
  26. <el-input v-model="form.contactName" placeholder="请输入联系人"></el-input>
  27. </el-form-item>
  28. <el-form-item label="联系电话" prop="contactPhone">
  29. <el-input v-model="form.contactPhone" placeholder="请输入联系电话"></el-input>
  30. </el-form-item>
  31. </el-form>
  32. <div class="demo-drawer__footer" style="display: flex;justify-content: end;margin-top: 200px;">
  33. <el-button :loading="buttonLoading" type="primary" @click="submitForm">保 存</el-button>
  34. <el-button @click="cancel" style="margin-right: 5%;">取 消</el-button>
  35. </div>
  36. </el-dialog>
  37. </el-card>
  38. </template>
  39. <script>
  40. export default {
  41. data () {
  42. return {
  43. pageTitle: '',
  44. dataList: [],
  45. loading: false,
  46. show: false,
  47. title: '新增举办方',
  48. form: {
  49. id: '',
  50. channelName: '',
  51. contactName: '',
  52. contactPhone: '',
  53. type: 2
  54. },
  55. rules: {
  56. channelName: [
  57. { required: true, message: '请输入举办方名称', trigger: 'blur' }
  58. ],
  59. contactName: [
  60. { required: true, message: '请输入联系人', trigger: 'blur' }
  61. ],
  62. contactPhone: [
  63. { required: true, message: '请输入联系电话', trigger: 'blur' },
  64. { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
  65. ]
  66. },
  67. buttonLoading: false
  68. }
  69. },
  70. mounted () {
  71. this.pageTitle = this.$router.currentRoute.meta.title
  72. this.getDataList()
  73. },
  74. methods: {
  75. handleAdd () {
  76. this.title = '新增举办方'
  77. this.show = true
  78. },
  79. handleEdit (row) {
  80. this.title = '编辑举办方'
  81. this.$http.get('/core/channel/' + row.id).then(({ data: res }) => {
  82. this.form = { ...this.form, ...res.data }
  83. this.show = true
  84. })
  85. },
  86. handleDelete (row) {
  87. this.$confirm(`确定要删除举办方【${row.channelName}】吗?`, '提示', {
  88. type: 'warning'
  89. }).then(() => {
  90. this.$http.delete('/core/channel', { 'data': [row.id] }).then(res => {
  91. if (res.data.code !== 0) return this.$message.error(res.data.msg)
  92. this.$message.success('删除成功')
  93. this.getDataList()
  94. })
  95. })
  96. },
  97. getDataList () {
  98. const params = { page: 1, limit: -1, type: 2 }
  99. this.$http.get('/core/channel/page', { params }).then(({ data: res }) => {
  100. if (res.code !== 0) return this.$message.error(res.msg)
  101. this.dataList = res.data.list
  102. })
  103. },
  104. submitForm () {
  105. this.$refs['formRef'].validate((valid) => {
  106. if (valid) {
  107. this.$http[this.form.id ? 'put' : 'post']('/core/channel', this.form).then(res => {
  108. if (res.data.code !== 0) {
  109. return this.$message.error(res.data.msg)
  110. }
  111. this.$message.success('保存成功')
  112. this.cancel()
  113. this.getDataList()
  114. })
  115. } else {
  116. return false
  117. }
  118. })
  119. },
  120. cancel () {
  121. this.form = {
  122. id: '',
  123. channelName: '',
  124. contactName: '',
  125. contactPhone: '',
  126. type: 2
  127. }
  128. this.$refs['formRef'].resetFields()
  129. this.show = false
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. .page-title{
  136. font-family: PingFang-SC, PingFang-SC;
  137. font-weight: bold;
  138. font-size: 16px;
  139. color: #252525;
  140. line-height: 22px;
  141. }
  142. .btns{
  143. justify-content: flex-end;
  144. margin-top: -10px;
  145. }
  146. </style>