index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title+'-列表', essential: true }]">
  3. <template slot-scope="{activeKey, data}">
  4. <template-page v-if="activeKey == 'list'" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  5. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing" :operationColumnWidth="80"
  6. :operation="operation()" :exportList="exportList">
  7. </template-page>
  8. </template>
  9. </zj-tab-page>
  10. </template>
  11. <script>
  12. import TemplatePage from '@/components/template/template-page-1.vue'
  13. import import_mixin from '@/components/template/import_mixin.js'
  14. import ImageUpload from '@/components/file-upload'
  15. import { downloadFiles } from '@/utils/util'
  16. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  17. import { listPageV2, pageExport, getDetail, listImport } from "@/api/salesPurchasing/goodsCodeMachineAccount";
  18. import { commonTemplateDownload } from '@/api/common.js'
  19. import operation_mixin from '@/components/template/operation_mixin.js'
  20. export default {
  21. components: { TemplatePage, ImageUpload },
  22. mixins: [import_mixin, operation_mixin],
  23. data() {
  24. return {
  25. // 表格属性
  26. tableAttributes: {
  27. // 启用勾选列
  28. selectColumn: true
  29. },
  30. // 表格事件
  31. tableEvents: {
  32. 'selection-change': this.selectionChange
  33. },
  34. // 勾选选中行
  35. recordSelected: [],
  36. /** 表单变量 */
  37. formDialogType: 0,
  38. formDialogTitles: ["新增", "编辑", "详情"],
  39. formDialog: false,
  40. formData: {},
  41. formType: 'add',
  42. formVisible: false,
  43. id: ''
  44. }
  45. },
  46. computed: {
  47. // 事件组合
  48. optionsEvensGroup() {
  49. return [
  50. [
  51. [
  52. this.optionsEvensAuth("imp", {
  53. name: '下载导入模板',
  54. click: () => {
  55. this.handleDownload()
  56. }
  57. })
  58. ],
  59. [
  60. this.optionsEvensAuth("imp", {
  61. render: () => {
  62. return this.importButton(listImport, '导入模板')
  63. }
  64. })
  65. ]
  66. ],
  67. ]
  68. },
  69. // 更多参数
  70. moreParameters() {
  71. return []
  72. },
  73. formItems() {
  74. return []
  75. }
  76. },
  77. created(){
  78. if(this.$route.query.id){
  79. this.id = this.$route.query.id
  80. }
  81. },
  82. methods: {
  83. // 列表请求函数
  84. getList(p, cb) {
  85. try {
  86. var pam = JSON.parse(JSON.stringify(p))
  87. if(this.id){
  88. pam.params.push({ "param": "a.goods_material_id", "compare": "=", "value": this.id })
  89. }
  90. cb && cb(pam)
  91. return listPageV2(pam)
  92. } catch (error) {
  93. console.log(error)
  94. }
  95. },
  96. // 列表导出函数
  97. exportList: pageExport,
  98. // 表格列解析渲染数据更改
  99. columnParsing(item, defaultData) {
  100. return defaultData
  101. },
  102. // 监听勾选变化
  103. selectionChange(data) {
  104. this.recordSelected = data
  105. },
  106. operation() {
  107. return this.operationBtn({
  108. })
  109. },
  110. formCancel() {
  111. this.formVisible = false
  112. this.$refs?.formRef?.resetFields()
  113. this.$data.formData = this.$options.data().formData
  114. },
  115. // 下载导入模版
  116. handleDownload() {
  117. commonTemplateDownload({ name: '初始化条码.xlsx' }, `${this.$route.meta.title}`).then(res => {
  118. this.$message({
  119. message: '下载成功',
  120. type: 'success'
  121. })
  122. }).catch(err => {
  123. this.$message.error('下载失败')
  124. })
  125. },
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .tab {
  131. padding: 20px 20px 0 20px;
  132. }
  133. </style>