index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <template-page v-if="pageShow" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes"
  3. :table-events="tableEvents" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
  4. :column-parsing="columnParsing" :exportList="exportList" :operation="operation()" key="pageType">
  5. <div slot="moreSearch">
  6. <el-radio-group v-model="pageType" size="mini" @input="changePageType">
  7. <el-radio-button label="list">列表</el-radio-button>
  8. <el-radio-button label="goodsder">商品明细</el-radio-button>
  9. <el-radio-button label="codeder">条码明细</el-radio-button>
  10. </el-radio-group>
  11. <br /><br />
  12. </div>
  13. <div class="cartographer_big">
  14. <el-dialog :title="formDialogTitles[formDialogType]" width="100%" :modal="false" :visible.sync="formDialog"
  15. :before-close="handleClose">
  16. <zj-page-container>
  17. <zj-page-fill>
  18. <div style="box-sizing: border-box; padding: 20px 20px 0 20px">
  19. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  20. <zj-form-module title="单据信息" label-width="100px" :form-data="formData" :form-items="formItems">
  21. </zj-form-module>
  22. <zj-form-module title="" label-width="100px" :form-data="formData" :form-items="formItems2">
  23. <el-tabs slot="header" v-model="activeName">
  24. <el-tab-pane label="商品信息" name="goodsInfo"></el-tab-pane>
  25. <el-tab-pane v-if="formDialogType > 0 && joinCode" label="条码信息" name="codeInfo"></el-tab-pane>
  26. </el-tabs>
  27. </zj-form-module>
  28. </zj-form-container>
  29. </div>
  30. </zj-page-fill>
  31. <div v-if="activeName == 'goodsInfo'" style="text-align: right; box-sizing: border-box; padding: 16px 20px">
  32. <el-button v-if="formDialogType == 0" size="mini" type="primary" @click="save">保存</el-button>
  33. <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="submit">提交</el-button>
  34. <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine">审核通过</el-button>
  35. </div>
  36. </zj-page-container>
  37. </el-dialog>
  38. </div>
  39. </template-page>
  40. </template>
  41. <script>
  42. import TemplatePage from '@/components/template/template-page-1.vue'
  43. import import_mixin from '@/components/template/import_mixin.js'
  44. import operation_mixin from '@/components/template/operation_mixin.js'
  45. import {
  46. goodsPurchaseList,
  47. goodsPurchaseListExport,
  48. goodsPurchaseItemList,
  49. goodsPurchaseItemListExport,
  50. goodsPurchaseCodeList,
  51. goodsPurchaseCodeListExport,
  52. goodsPurchaseAdd,
  53. goodsPurchaseDetail,
  54. goodsPurchaseSubmit,
  55. goodsPurchaseConfirm,
  56. goodsPurchaseDel
  57. } from '@/api/goodsPurchasedStored.js'
  58. import form_ty from '../mixins/common_form'
  59. import storage_table from '../mixins/storage_table'
  60. import storage_goods from '../mixins/storage_goods'
  61. import storage_codes from '../mixins/storage_codes'
  62. import common from '../mixins/common_code'
  63. export default {
  64. components: { TemplatePage },
  65. mixins: [import_mixin, operation_mixin, form_ty, storage_table, storage_goods, storage_codes, common],
  66. data() {
  67. return {
  68. pageType: 'list',
  69. pageShow: true,
  70. // 表格属性
  71. tableAttributes: {
  72. // 启用勾选列
  73. selectColumn: false
  74. },
  75. // 表格事件
  76. tableEvents: {
  77. 'selection-change': this.selectionChange
  78. },
  79. // 勾选选中行
  80. recordSelected: [],
  81. /** 表单变量 */
  82. formDialogType: 0,
  83. formDialogTitles: ['新增入库单', '编辑入库单', '入库单详情', '审核入库单'],
  84. formDialog: false,
  85. appraise_status: '',
  86. formData: {
  87. companyWechatId: '',
  88. companyWechatName: '',
  89. examineBy: '',
  90. examineTime: '',
  91. fileUrl: '',
  92. remark: '',
  93. status: '',
  94. submitBy: '',
  95. submitTime: '',
  96. totalAmount: 0,
  97. totalQty: 0,
  98. updateBy: '',
  99. updateTime: '',
  100. venderId: '',
  101. venderName: '',
  102. fileUrl: [],
  103. items: [],
  104. codeInfoList: []
  105. },
  106. activeName: 'goodsInfo',
  107. goods_material_id: '',
  108. joinCode: false
  109. }
  110. },
  111. computed: {
  112. // 事件组合
  113. optionsEvensGroup() {
  114. if (this.pageType == 'list') {
  115. return [
  116. [
  117. [
  118. this.optionsEvensAuth('add', {
  119. click: () => {
  120. this.openForm()
  121. this.formDialog = true
  122. this.joinCode = JSON.parse(localStorage.getItem('greemall_user')).joinCode
  123. }
  124. })
  125. ]
  126. ]
  127. ]
  128. } else if (this.pageType == 'goodsder') {
  129. return []
  130. } else if (this.pageType == 'codeder') {
  131. return []
  132. }
  133. },
  134. // 更多参数
  135. moreParameters() {
  136. return []
  137. }
  138. },
  139. watch: {
  140. pageType() {
  141. this.handleClose()
  142. this.pageShow = false
  143. this.$nextTick(() => {
  144. this.pageShow = true
  145. })
  146. }
  147. },
  148. methods: {
  149. changePageType() {
  150. this.goods_material_id = ''
  151. },
  152. // 列表请求函数
  153. getList(p, cb) {
  154. if (this.pageType == 'list') {
  155. return goodsPurchaseList(p)
  156. } else if (this.pageType == 'goodsder') {
  157. return goodsPurchaseItemList(p)
  158. } else if (this.pageType == 'codeder') {
  159. if (this.goods_material_id) {
  160. return goodsPurchaseCodeList({
  161. ...p,
  162. params: [...p.params, { param: 'b.goods_material_id', compare: '=', value: this.goods_material_id }]
  163. })
  164. } else {
  165. return goodsPurchaseCodeList(p)
  166. }
  167. }
  168. },
  169. // 列表导出函数
  170. exportList(...p) {
  171. if (this.pageType == 'list') {
  172. return goodsPurchaseListExport(...p)
  173. } else if (this.pageType == 'goodsder') {
  174. return goodsPurchaseItemListExport(...p)
  175. } else if (this.pageType == 'codeder') {
  176. return goodsPurchaseCodeListExport(...p)
  177. }
  178. },
  179. // 表格列解析渲染数据更改
  180. columnParsing(item, defaultData) {
  181. return defaultData
  182. },
  183. // 监听勾选变化
  184. selectionChange(data) {
  185. this.recordSelected = data
  186. },
  187. // 打开创建弹窗
  188. openForm() {
  189. this.getGysList()
  190. this.getBaseList()
  191. },
  192. // 打开详情弹窗
  193. openDetailForm(row, type) {
  194. goodsPurchaseDetail({ id: row.id }).then(res => {
  195. Object.assign(this.formData, res.data, {
  196. fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
  197. items: res.data.items.map(item => ({ ...item, details: {} }))
  198. })
  199. this.joinCode = res.data.joinCode
  200. this.formDialogType = type
  201. this.openForm()
  202. this.formDialog = true
  203. })
  204. },
  205. // 关闭弹窗
  206. handleClose() {
  207. this.$refs?.formRef?.resetFields()
  208. this.$data.formData = this.$options.data().formData
  209. this.formDialog = false
  210. this.formDialogType = 0
  211. this.activeName = 'goodsInfo'
  212. this.joinCode = false
  213. },
  214. // 操作按钮
  215. operation() {
  216. if (this.pageType == 'list') {
  217. return this.operationBtn({
  218. edit: {
  219. conditions: ({ row, index, column }) => {
  220. return row.status == 'SAVE'
  221. },
  222. click: ({ row, index, column }) => {
  223. this.openDetailForm(row, 1)
  224. }
  225. },
  226. del: {
  227. prompt: '是否确定删除',
  228. conditions: ({ row, index, column }) => {
  229. return row.status == 'SAVE'
  230. },
  231. click: ({ row, index, column }) => {
  232. goodsPurchaseDel({
  233. id: row.id
  234. }).then(res => {
  235. this.$message({
  236. type: 'success',
  237. message: '删除成功'
  238. })
  239. this.$refs.pageRef.refreshList()
  240. })
  241. }
  242. },
  243. detail: {
  244. click: ({ row, index, column }) => {
  245. this.openDetailForm(row, 2)
  246. }
  247. },
  248. shenhe: {
  249. conditions: ({ row, index, column }) => {
  250. return row.status == 'WAIT'
  251. },
  252. click: ({ row, index, column }) => {
  253. this.openDetailForm(row, 3)
  254. }
  255. }
  256. })
  257. } else if (this.pageType == 'goodsder') {
  258. return this.operationBtn({
  259. codeDetail: {
  260. click: ({ row, index, column }) => {
  261. this.goods_material_id = row.goodsMaterialId
  262. this.pageType = 'codeder'
  263. }
  264. }
  265. })
  266. } else if (this.pageType == 'codeder') {
  267. return undefined
  268. }
  269. },
  270. // 保存
  271. save() {
  272. this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
  273. if (valid && this.eidtItems()) {
  274. goodsPurchaseAdd({
  275. ...this.formData,
  276. items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
  277. fileUrl: this.formData.fileUrl.map(item => item.url).join(','),
  278. codeInfoList: undefined
  279. }).then(res => {
  280. this.$message({
  281. type: 'success',
  282. message: '保存成功'
  283. })
  284. this.handleClose()
  285. this.$refs.pageRef.refreshList()
  286. })
  287. }
  288. })
  289. },
  290. // 提交
  291. submit() {
  292. goodsPurchaseSubmit({
  293. id: this.formData.id
  294. }).then(res => {
  295. this.$message({
  296. type: 'success',
  297. message: '提交成功'
  298. })
  299. this.handleClose()
  300. this.$refs.pageRef.refreshList()
  301. })
  302. },
  303. // 审核
  304. examine() {
  305. goodsPurchaseConfirm({
  306. id: this.formData.id,
  307. statusEnum: 'OK'
  308. }).then(res => {
  309. this.$message({
  310. type: 'success',
  311. message: '审核成功'
  312. })
  313. this.handleClose()
  314. this.$refs.pageRef.refreshList()
  315. })
  316. }
  317. }
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. .tab {
  322. padding: 20px 20px 0 20px;
  323. }
  324. ::v-deep .teshudeshangchuananniu {
  325. color: #409eff !important;
  326. }
  327. </style>