index.vue 4.2 KB

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