index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. :operation="operation()"
  14. :exportList="exportList"
  15. >
  16. </template-page>
  17. <div v-if="~['add', 'examine', 'detail'].indexOf(activeKey)">
  18. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  19. <zj-form-module
  20. title=""
  21. label-width="100px"
  22. :showPackUp="false"
  23. :form-data="formData"
  24. :form-items="formItems"
  25. >
  26. </zj-form-module>
  27. </zj-form-container>
  28. <div slot="footer" class="dialog-footer">
  29. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  30. <el-button v-if="formDialogType !== 2" size="mini" @click="formConfirm(data.removeTab)" type="primary"
  31. >确 定</el-button
  32. >
  33. </div>
  34. </div>
  35. </template>
  36. </zj-tab-page>
  37. </template>
  38. <script>
  39. import TemplatePage from '@/components/template/template-page-1.vue'
  40. import import_mixin from '@/components/template/import_mixin.js'
  41. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  42. import {
  43. websitGoodsMoveList,
  44. websitGoodsMoveListExport,
  45. websitGoodsMoveAdd,
  46. websitGoodsMoveDetail,
  47. websitGoodsMoveConfirm,
  48. websitGoodsMoveSubmit,
  49. websitGoodsMoveDel
  50. } from '@/api/AuxiliaryAccessoriesWarehouse'
  51. import ImageUpload from '@/components/file-upload'
  52. import operation_mixin from '@/components/template/operation_mixin.js'
  53. export default {
  54. components: { TemplatePage, ImageUpload },
  55. mixins: [import_mixin, operation_mixin],
  56. data() {
  57. return {
  58. // 表格属性
  59. tableAttributes: {
  60. // 启用勾选列
  61. selectColumn: false
  62. },
  63. // 表格事件
  64. tableEvents: {
  65. 'selection-change': this.selectionChange
  66. },
  67. // 勾选选中行
  68. recordSelected: [],
  69. /** 表单变量 */
  70. formDialogType: 0,
  71. formDialogTitles: ['新增', '审核', '查看'],
  72. formDialog: false,
  73. formData: {
  74. chargingStandardTypeId: '',
  75. brandId: '',
  76. oneCategoryId: '',
  77. twoCategoryId: '',
  78. status: true
  79. },
  80. businessTypeList: [], // 业务类型列表
  81. brandList: [], // 品牌列表
  82. mainList: [], // 一级分类列表
  83. smallList: [], // 二级分类列表
  84. formVisible: false
  85. }
  86. },
  87. computed: {
  88. // 事件组合
  89. optionsEvensGroup() {
  90. return [
  91. [
  92. [
  93. this.optionsEvensAuth('add', {
  94. click: () => {
  95. this.openForm('add')
  96. }
  97. })
  98. ]
  99. ]
  100. ]
  101. },
  102. // 更多参数
  103. moreParameters() {
  104. return []
  105. },
  106. formItems() {
  107. return []
  108. }
  109. },
  110. methods: {
  111. // 列表请求函数
  112. getList: websitGoodsMoveList,
  113. // 列表导出函数
  114. exportList: websitGoodsMoveListExport,
  115. // 表格列解析渲染数据更改
  116. columnParsing(item, defaultData) {
  117. return defaultData
  118. },
  119. // 监听勾选变化
  120. selectionChange(data) {
  121. this.recordSelected = data
  122. },
  123. // 表格操作列
  124. operation() {
  125. return this.operationBtn({
  126. view: {
  127. btnType: 'text',
  128. click: ({ row, index, column }) => {
  129. this.openForm('detail', row.id)
  130. }
  131. },
  132. examine: {
  133. btnType: 'text',
  134. click: ({ row, index, column }) => {
  135. this.openForm('examine', row.id)
  136. }
  137. }
  138. })
  139. },
  140. // 取消 新增编辑
  141. formCancel() {
  142. this.formVisible = false
  143. this.$refs?.formRef?.resetFields()
  144. this.$data.formData = this.$options.data().formData
  145. },
  146. // 打开 新增编辑 网点表单
  147. openForm(type, id) {
  148. this.$refs.tabPage.addTab({
  149. // 对应显示的模块
  150. activeKey: type,
  151. // 唯一标识
  152. key: type,
  153. // 页签名称
  154. label: { edit: 'examine', add: '新增', detail: '查看' }[type],
  155. // 打开时事件
  156. triggerEvent: () => {
  157. this.formCancel()
  158. this.$nextTick(() => {
  159. this.formVisible = true
  160. if (type == 'add') {
  161. this.formDialogType = 0
  162. this.initData()
  163. } else if (type == 'examine') {
  164. this.formDialogType = 1
  165. websitGoodsMoveDetail({ id }).then(res => {
  166. Object.assign(this.formData, res.data)
  167. this.initData()
  168. })
  169. } else {
  170. this.formDialogType = 2
  171. websitGoodsMoveDetail({ id }).then(res => {
  172. Object.assign(this.formData, res.data)
  173. this.initData()
  174. })
  175. }
  176. })
  177. },
  178. // 关闭时事件
  179. closeEvent: () => {}
  180. })
  181. },
  182. initData() {
  183. // Promise.all([
  184. // ]).then(([res1, res2, res3]) => {
  185. // })
  186. },
  187. formConfirm(cancel) {
  188. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  189. if (valid) {
  190. if (this.formDialogType == 0) {
  191. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  192. this.$message({
  193. type: 'success',
  194. message: this.formDialogTitles[this.formDialogType] + `成功!`
  195. })
  196. cancel('list')
  197. this.$refs.pageRef.refreshList()
  198. })
  199. } else if (this.formDialogType == 1) {
  200. websitGoodsMoveConfirm({ ...this.formData }).then(res => {
  201. this.$message({
  202. type: 'success',
  203. message: this.formDialogTitles[this.formDialogType] + `成功!`
  204. })
  205. cancel('list')
  206. this.$refs.pageRef.refreshList()
  207. })
  208. }
  209. }
  210. })
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped></style>