index.vue 11 KB

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