index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. <div style="box-sizing: border-box; padding: 20px">
  19. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  20. <zj-form-module
  21. title="单据信息"
  22. label-width="100px"
  23. :showPackUp="false"
  24. :form-data="formData"
  25. :form-items="formItems"
  26. >
  27. </zj-form-module>
  28. <zj-form-module
  29. title="产品信息"
  30. label-width="100px"
  31. :showPackUp="false"
  32. :form-data="formData"
  33. :form-items="formItems2"
  34. >
  35. </zj-form-module>
  36. </zj-form-container>
  37. <div slot="footer" class="dialog-footer">
  38. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  39. <el-button v-if="formDialogType !== 2" size="mini" @click="formSubmit(data.removeTab)" type="primary"
  40. >保 存</el-button
  41. >
  42. <el-button v-if="formDialogType == 1" size="mini" @click="formConfirm(data.removeTab)" type="primary"
  43. >审 核</el-button
  44. >
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. </zj-tab-page>
  50. </template>
  51. <script>
  52. import TemplatePage from '@/components/template/template-page-1.vue'
  53. import import_mixin from '@/components/template/import_mixin.js'
  54. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  55. import {
  56. websitGoodsMoveList,
  57. websitGoodsMoveListExport,
  58. websitGoodsMoveAdd,
  59. websitGoodsMoveSubmit,
  60. websitGoodsMoveDetail,
  61. websitGoodsMoveConfirm,
  62. websitGoodsMoveDel
  63. } from '@/api/AuxiliaryAccessoriesWarehouse'
  64. import ImageUpload from '@/components/file-upload'
  65. import operation_mixin from '@/components/template/operation_mixin.js'
  66. import editTable from '@/components/template/editTable.js'
  67. import { getWebsit } from '@/api/customerManagement.js'
  68. import { storageListPageV2 } from '@/api/storage'
  69. import { materialCategoryList } from '@/api/auxiliaryMaterialClass'
  70. import storage_table from './storage_table.js'
  71. export default {
  72. components: { TemplatePage, ImageUpload },
  73. mixins: [import_mixin, operation_mixin, storage_table],
  74. data() {
  75. return {
  76. // 表格属性
  77. tableAttributes: {
  78. // 启用勾选列
  79. selectColumn: false
  80. },
  81. // 表格事件
  82. tableEvents: {
  83. 'selection-change': this.selectionChange
  84. },
  85. // 勾选选中行
  86. recordSelected: [],
  87. /** 表单变量 */
  88. formDialogType: 0,
  89. formDialogTitles: ['新增', '审核', '查看'],
  90. formData: {
  91. companyWechatId: '',
  92. companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  93. examineBy: '',
  94. examineTime: '',
  95. inStorageId: '',
  96. inStorageName: '',
  97. items: [],
  98. outStorageId: '',
  99. outStorageName: '',
  100. remark: '',
  101. status: '',
  102. submitBy: '',
  103. submitTime: '',
  104. totalQty: '',
  105. type: '',
  106. websitId: '',
  107. websitName: ''
  108. },
  109. websitSelectList: [],
  110. warehouseList: []
  111. }
  112. },
  113. computed: {
  114. // 事件组合
  115. optionsEvensGroup() {
  116. return [
  117. [
  118. [
  119. this.optionsEvensAuth('add', {
  120. click: () => {
  121. this.openForm('add')
  122. }
  123. })
  124. ]
  125. ]
  126. ]
  127. },
  128. // 更多参数
  129. moreParameters() {
  130. return []
  131. },
  132. formItems() {
  133. return [
  134. {
  135. md: 6,
  136. isShow: true,
  137. name: 'el-select',
  138. options: [
  139. { label: '保存', value: 'SAVE' },
  140. { label: '待审核', value: 'WAIT' },
  141. { label: '通过', value: 'OK' },
  142. { label: '失败', value: 'FAIL' }
  143. ],
  144. attributes: { disabled: true },
  145. formItemAttributes: {
  146. label: '单据状态',
  147. prop: 'status',
  148. rules: []
  149. }
  150. },
  151. {
  152. md: 6,
  153. isShow: true,
  154. name: 'el-input',
  155. attributes: { placeholder: '', disabled: true },
  156. formItemAttributes: {
  157. label: '单据编号',
  158. prop: 'id',
  159. rules: []
  160. }
  161. },
  162. {
  163. md: 6,
  164. isShow: true,
  165. name: 'el-input',
  166. attributes: { placeholder: '请输入', disabled: true },
  167. formItemAttributes: {
  168. label: '所属商户',
  169. prop: 'companyWechatName',
  170. rules: []
  171. }
  172. },
  173. {
  174. md: 6,
  175. isShow: true,
  176. name: 'el-select',
  177. options: this.websitSelectList.map(item => ({ label: item.name, value: item.websitId })),
  178. attributes: {},
  179. formItemAttributes: {
  180. label: '网点名称',
  181. prop: 'websitId',
  182. rules: [...required]
  183. },
  184. events: {
  185. change: () => {
  186. this.formData.outStorageId = ''
  187. this.formData.inStorageId = ''
  188. this.formData.items = []
  189. }
  190. }
  191. },
  192. {
  193. md: 6,
  194. name: 'el-radio',
  195. options: [
  196. // { label: '商品', value: 'G' }
  197. { label: '辅材', value: 'M' },
  198. { label: '配件', value: 'P' }
  199. ],
  200. attributes: {
  201. disabled: this.formDialogType == 2
  202. },
  203. formItemAttributes: {
  204. label: '调仓产品',
  205. prop: 'type',
  206. rules: [...required]
  207. }
  208. },
  209. {
  210. md: 6,
  211. isShow: true,
  212. name: 'el-select',
  213. options: this.warehouseList
  214. .map(item => ({ label: item.storageName, value: item.storageId }))
  215. .filter(item => item.value !== this.formData.inStorageId),
  216. attributes: {
  217. disabled: this.formDialogType == 2
  218. },
  219. formItemAttributes: {
  220. label: '调出仓库',
  221. prop: 'outStorageId',
  222. rules: [...required]
  223. }
  224. },
  225. {
  226. md: 6,
  227. isShow: true,
  228. name: 'el-select',
  229. options: this.warehouseList
  230. .map(item => ({ label: item.storageName, value: item.storageId }))
  231. .filter(item => item.value !== this.formData.outStorageId),
  232. attributes: {
  233. disabled: this.formDialogType == 2
  234. },
  235. formItemAttributes: {
  236. label: '调入仓库',
  237. prop: 'inStorageId',
  238. rules: [...required]
  239. }
  240. },
  241. {
  242. md: 6,
  243. isShow: true,
  244. name: 'slot-component',
  245. attributes: { placeholder: '' },
  246. formItemAttributes: {
  247. label: '',
  248. prop: '',
  249. 'label-width': '0px'
  250. },
  251. render: (h, { props, onInput }) => {
  252. return <div></div>
  253. }
  254. },
  255. {
  256. md: 6,
  257. isShow: true,
  258. name: 'el-input',
  259. attributes: { placeholder: '请输入', disabled: true },
  260. formItemAttributes: {
  261. label: '制单人',
  262. prop: 'createBy',
  263. rules: []
  264. }
  265. },
  266. {
  267. md: 6,
  268. isShow: true,
  269. name: 'el-input',
  270. attributes: { placeholder: '请输入', disabled: true },
  271. formItemAttributes: {
  272. label: '制单时间',
  273. prop: 'createTime',
  274. rules: []
  275. }
  276. },
  277. {
  278. md: 6,
  279. isShow: true,
  280. name: 'el-input',
  281. attributes: { placeholder: '请输入', disabled: true },
  282. formItemAttributes: {
  283. label: '审核人',
  284. prop: 'examineBy',
  285. rules: []
  286. }
  287. },
  288. {
  289. md: 6,
  290. isShow: true,
  291. name: 'el-input',
  292. attributes: { placeholder: '请输入', disabled: true },
  293. formItemAttributes: {
  294. label: '审核时间',
  295. prop: 'examineTime',
  296. rules: []
  297. }
  298. },
  299. {
  300. md: 24,
  301. isShow: true,
  302. name: 'el-input',
  303. attributes: { placeholder: '请输入', type: 'textarea', rows: 5, disabled: this.formDialogType == 2 },
  304. formItemAttributes: {
  305. label: '备注',
  306. prop: 'remark',
  307. rules: []
  308. }
  309. }
  310. ]
  311. }
  312. },
  313. methods: {
  314. // 列表请求函数
  315. getList: websitGoodsMoveList,
  316. // 列表导出函数
  317. exportList: websitGoodsMoveListExport,
  318. // 表格列解析渲染数据更改
  319. columnParsing(item, defaultData) {
  320. return defaultData
  321. },
  322. // 监听勾选变化
  323. selectionChange(data) {
  324. this.recordSelected = data
  325. },
  326. // 表格操作列
  327. operation() {
  328. return this.operationBtn({
  329. view: {
  330. btnType: 'text',
  331. click: ({ row, index, column }) => {
  332. this.openForm('detail', row.id)
  333. }
  334. },
  335. examine: {
  336. btnType: 'text',
  337. conditions: ({ row, index, column }) => {
  338. return row.status !== 'OK'
  339. },
  340. click: ({ row, index, column }) => {
  341. this.openForm('examine', row.id)
  342. }
  343. }
  344. })
  345. },
  346. // 取消 新增编辑
  347. formCancel() {
  348. this.$refs?.formRef?.resetFields()
  349. this.$data.formData = this.$options.data().formData
  350. },
  351. // 打开 新增编辑 网点表单
  352. openForm(type, id) {
  353. this.$refs.tabPage.addTab({
  354. // 对应显示的模块
  355. activeKey: type,
  356. // 唯一标识
  357. key: type,
  358. // 页签名称
  359. label: { examine: '审核', add: '新增', detail: '查看' }[type],
  360. // 打开时事件
  361. triggerEvent: () => {
  362. this.formCancel()
  363. this.$nextTick(() => {
  364. if (type == 'add') {
  365. this.formDialogType = 0
  366. this.initData()
  367. } else if (type == 'examine') {
  368. this.formDialogType = 1
  369. websitGoodsMoveDetail({ id }).then(res => {
  370. Object.assign(this.formData, res.data)
  371. this.initData()
  372. })
  373. } else {
  374. this.formDialogType = 2
  375. websitGoodsMoveDetail({ id }).then(res => {
  376. Object.assign(this.formData, res.data)
  377. this.initData()
  378. })
  379. }
  380. })
  381. },
  382. // 关闭时事件
  383. closeEvent: () => {}
  384. })
  385. },
  386. initData() {
  387. Promise.all([getWebsit({ type: 'C', status: true })]).then(([res1]) => {
  388. this.websitSelectList = res1.data
  389. this.biyaowebsitId(this.formData.websitId)
  390. this.biyaooutStorageId(this.formData.outStorageId)
  391. })
  392. },
  393. formSubmit(cancel) {
  394. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  395. if (valid) {
  396. if (this.formDialogType == 0) {
  397. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  398. this.$message({
  399. type: 'success',
  400. message: `保存成功!`
  401. })
  402. cancel('list')
  403. this.$refs.pageRef.refreshList()
  404. })
  405. } else if (this.formDialogType == 1) {
  406. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  407. this.$message({
  408. type: 'success',
  409. message: `保存成功!`
  410. })
  411. cancel('list')
  412. this.$refs.pageRef.refreshList()
  413. })
  414. }
  415. }
  416. })
  417. },
  418. formConfirm(cancel) {
  419. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  420. if (valid) {
  421. if (this.formData.status == 'WAIT') {
  422. websitGoodsMoveConfirm({ id: this.formData.id, statusEnum: 'OK' }).then(res => {
  423. this.$message({
  424. type: 'success',
  425. message: `审核成功!`
  426. })
  427. cancel('list')
  428. this.$refs.pageRef.refreshList()
  429. // 备注
  430. })
  431. } else {
  432. websitGoodsMoveAdd({ ...this.formData }).then(res => {
  433. websitGoodsMoveSubmit({ id: this.formData.id }).then(res => {
  434. websitGoodsMoveConfirm({ id: this.formData.id, statusEnum: 'OK' }).then(res => {
  435. this.$message({
  436. type: 'success',
  437. message: `审核成功!`
  438. })
  439. cancel('list')
  440. this.$refs.pageRef.refreshList()
  441. // 备注
  442. })
  443. })
  444. })
  445. }
  446. }
  447. })
  448. }
  449. }
  450. }
  451. </script>
  452. <style lang="scss" scoped></style>