index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="50"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation">
  5. <!-- :exportList="exportList" -->
  6. </template-page>
  7. </template>
  8. <script>
  9. import TemplatePage from '@/components/template/template-page-1.vue'
  10. import import_mixin from '@/components/template/import_mixin.js'
  11. import ImageUpload from '@/components/file-upload'
  12. import { downloadFiles } from '@/utils/util'
  13. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  14. import { listPageV2,pageExport, del, listImport } from "@/api/workerProfileInit";
  15. import { commonTemplateDownload } from '@/api/common.js'
  16. export default {
  17. components: { TemplatePage, ImageUpload },
  18. mixins: [import_mixin],
  19. data() {
  20. return {
  21. // 事件组合
  22. optionsEvensGroup: [
  23. [
  24. [
  25. {
  26. name: '导入模板',
  27. click: this.handleDownload
  28. }
  29. ],
  30. [
  31. {
  32. name: '导入师傅资料',
  33. render: () => {
  34. return this.importButton(listImport, '导入师傅资料')
  35. }
  36. }
  37. ],
  38. ]
  39. ],
  40. // 表格属性
  41. tableAttributes: {
  42. // 启用勾选列
  43. selectColumn: true
  44. },
  45. // 表格事件
  46. tableEvents: {
  47. 'selection-change': this.selectionChange
  48. },
  49. // 勾选选中行
  50. recordSelected: [],
  51. /** 表单变量 */
  52. formDialogType: 0,
  53. formDialogTitles: ["新增","编辑", "详情"],
  54. formDialog: false,
  55. formData: {},
  56. }
  57. },
  58. computed: {
  59. // 更多参数
  60. moreParameters() {
  61. return []
  62. },
  63. formItems() {}
  64. },
  65. methods: {
  66. // 列表请求函数
  67. getList(p,cb) {
  68. try {
  69. var pam = JSON.parse(JSON.stringify(p))
  70. // if (this.examineStatus) {
  71. // pam.params.push({ "param": "b.examine_status", "compare": "=", "value": this.examineStatus })
  72. // }
  73. cb && cb(pam)
  74. return listPageV2(pam)
  75. } catch (error) {
  76. console.log(error)
  77. }
  78. },
  79. // 列表导出函数
  80. exportList: pageExport,
  81. // 表格列解析渲染数据更改
  82. columnParsing(item, defaultData) {
  83. return defaultData
  84. },
  85. // 监听勾选变化
  86. selectionChange(data) {
  87. this.recordSelected = data
  88. },
  89. // 表格操作列
  90. operation(h, { row, index, column }) {
  91. return (
  92. <div class='operation-btns'>
  93. <el-button type="text" onClick={() => {
  94. this.$confirm(`请确认是否删除该数据, 是否继续?`, '提示', {
  95. confirmButtonText: '确定',
  96. cancelButtonText: '取消',
  97. type: 'warning'
  98. }).then(() => {
  99. del({
  100. id: row.id
  101. }).then(res => {
  102. if (res.code == 200) {
  103. this.$message({ type: 'success', message: `删除成功!` })
  104. this.$refs.pageRef.refreshList()
  105. } else {
  106. this.$message.error(res.msg);
  107. }
  108. })
  109. });
  110. }}>删除</el-button>
  111. </div>
  112. )
  113. },
  114. addData() {
  115. this.formDialogType = 0
  116. this.openForm()
  117. },
  118. openForm() {
  119. this.formDialog = true;
  120. },
  121. formCancel() {
  122. this.$refs.formRef.$refs.inlineForm.clearValidate()
  123. this.$data.formData = this.$options.data().formData
  124. this.formDialog = false
  125. },
  126. formConfirm() {
  127. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  128. if (valid) {
  129. ([add, edit][this.formDialogType])(this.formData).then(res => {
  130. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  131. this.formCancel()
  132. this.$refs.pageRef.refreshList()
  133. })
  134. }
  135. })
  136. },
  137. handleDownload() {
  138. commonTemplateDownload({ name: '师傅分销员资料初始化.xlsx' }, `${this.$route.meta.title}`).then(res => {
  139.     this.$message({
  140.         message: '下载成功',
  141.         type: 'success'
  142.     })
  143. }).catch(err => {
  144.     this.$message.error('下载失败')
  145. })
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .tab{
  152. padding: 20px 20px 0 20px;
  153. }
  154. </style>