index.vue 11 KB

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