index.vue 11 KB

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