index.vue 11 KB

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