DisassembleModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="width"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. :keyboard="false"
  8. :forceRender="true"
  9. v-bind:prefixNo="prefixNo"
  10. fullscreen
  11. switchFullscreen
  12. @cancel="handleCancel"
  13. :id="prefixNo"
  14. style="top: 20px; height: 95%"
  15. >
  16. <template slot="footer">
  17. <a-button @click="handleCancel">取消</a-button>
  18. <a-button v-if="billPrintFlag && isShowPrintBtn" @click="handlePrint('拆卸单')">三联打印预览</a-button>
  19. <a-button v-if="checkFlag && isCanCheck" :loading="confirmLoading" @click="handleOkAndCheck">保存并审核</a-button>
  20. <a-button type="primary" :loading="confirmLoading" @click="handleOk">保存(Ctrl+S)</a-button>
  21. <!--发起多级审核-->
  22. <a-button v-if="!checkFlag" @click="handleWorkflow()" type="primary">提交流程</a-button>
  23. </template>
  24. <a-spin :spinning="confirmLoading">
  25. <a-form :form="form">
  26. <a-row class="form-row" :gutter="24">
  27. <a-col :lg="6" :md="12" :sm="24">
  28. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  29. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  30. </a-form-item>
  31. </a-col>
  32. <a-col :lg="6" :md="12" :sm="24">
  33. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据编号">
  34. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  35. </a-form-item>
  36. </a-col>
  37. <a-col :lg="6" :md="12" :sm="24"></a-col>
  38. <a-col :lg="6" :md="12" :sm="24"></a-col>
  39. </a-row>
  40. <j-editable-table
  41. id="billModal"
  42. :ref="refKeys[0]"
  43. :loading="materialTable.loading"
  44. :columns="materialTable.columns"
  45. :dataSource="materialTable.dataSource"
  46. :minWidth="minWidth"
  47. :maxHeight="300"
  48. :rowNumber="true"
  49. :rowSelection="true"
  50. :actionButton="true"
  51. @valueChange="onValueChange"
  52. @added="onAdded"
  53. @deleted="onDeleted"
  54. >
  55. <template #buttonAfter>
  56. <a-row
  57. :gutter="24"
  58. style="float: left"
  59. data-step="4"
  60. data-title="扫码录入"
  61. data-intro="此功能支持扫码枪扫描商品条码进行录入"
  62. >
  63. <a-col v-if="scanStatus" :md="6" :sm="24">
  64. <a-button @click="scanEnter">扫码录入</a-button>
  65. </a-col>
  66. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 6px 0 12px">
  67. <a-input
  68. placeholder="请扫描商品条码并回车"
  69. v-model="scanBarCode"
  70. @pressEnter="scanPressEnter"
  71. ref="scanBarCode"
  72. />
  73. </a-col>
  74. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px">
  75. <a-button @click="stopScan">收起扫码</a-button>
  76. </a-col>
  77. </a-row>
  78. </template>
  79. <template #depotBatchSet>
  80. <a-icon type="down" @click="handleBatchSetDepot" />
  81. </template>
  82. <template #depotAdd>
  83. <a-divider v-if="quickBtn.depot" style="margin: 4px 0" />
  84. <div v-if="quickBtn.depot" style="padding: 4px 8px; cursor: pointer" @click="addDepot">
  85. <a-icon type="plus" /> 新增仓库
  86. </div>
  87. </template>
  88. </j-editable-table>
  89. <a-row class="form-row" :gutter="24">
  90. <a-col :lg="24" :md="24" :sm="24">
  91. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  92. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  93. </a-form-item>
  94. </a-col>
  95. </a-row>
  96. <a-row class="form-row" :gutter="24">
  97. <a-col :lg="6" :md="12" :sm="24">
  98. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="附件">
  99. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  100. </a-form-item>
  101. </a-col>
  102. </a-row>
  103. </a-form>
  104. </a-spin>
  105. <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
  106. <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  107. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  108. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  109. </j-modal>
  110. </template>
  111. <script>
  112. import pick from 'lodash.pick'
  113. import DepotModal from '../../system/modules/DepotModal'
  114. import BatchSetDepot from '../dialog/BatchSetDepot'
  115. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  116. import BillPrintIframe from '../dialog/BillPrintIframe'
  117. import { FormTypes } from '@/utils/JEditableTableUtil'
  118. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  119. import { BillModalMixin } from '../mixins/BillModalMixin'
  120. import { getAction } from '@/api/manage'
  121. import { getMpListShort } from '@/utils/util'
  122. import JUpload from '@/components/jeecg/JUpload'
  123. import JDate from '@/components/jeecg/JDate'
  124. import Vue from 'vue'
  125. export default {
  126. name: 'DisassembleModal',
  127. mixins: [JEditableTableMixin, BillModalMixin],
  128. components: {
  129. DepotModal,
  130. BatchSetDepot,
  131. WorkflowIframe,
  132. BillPrintIframe,
  133. JUpload,
  134. JDate,
  135. },
  136. data() {
  137. return {
  138. title: '操作',
  139. width: '1600px',
  140. moreStatus: false,
  141. // 新增时子表默认添加几行空数据
  142. addDefaultRowNum: 1,
  143. visible: false,
  144. operTimeStr: '',
  145. prefixNo: 'CXD',
  146. fileList: [],
  147. model: {},
  148. labelCol: {
  149. xs: { span: 24 },
  150. sm: { span: 8 },
  151. },
  152. wrapperCol: {
  153. xs: { span: 24 },
  154. sm: { span: 16 },
  155. },
  156. refKeys: ['materialDataTable'],
  157. activeKey: 'materialDataTable',
  158. materialTable: {
  159. loading: false,
  160. dataSource: [],
  161. columns: [
  162. { title: '商品类型', key: 'mType', width: '7%', type: FormTypes.normal },
  163. {
  164. title: '仓库名称',
  165. key: 'depotId',
  166. width: '8%',
  167. type: FormTypes.select,
  168. placeholder: '请选择${title}',
  169. options: [],
  170. allowSearch: true,
  171. validateRules: [{ required: true, message: '${title}不能为空' }],
  172. },
  173. {
  174. title: '批次号',
  175. key: 'batchNumber',
  176. width: '12%',
  177. type: FormTypes.popupJsh,
  178. kind: 'material',
  179. multi: true,
  180. validateRules: [{ required: true, message: '${title}不能为空' }],
  181. },
  182. { title: '名称', key: 'name', width: '10%', type: FormTypes.normal },
  183. { title: '规格', key: 'standard', width: '9%', type: FormTypes.normal },
  184. { title: '型号', key: 'model', width: '9%', type: FormTypes.normal },
  185. { title: '颜色', key: 'color', width: '5%', type: FormTypes.normal },
  186. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  187. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  188. { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
  189. { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
  190. { title: '单位', key: 'unit', width: '4%', type: FormTypes.normal },
  191. { title: '多属性', key: 'sku', width: '4%', type: FormTypes.normal },
  192. {
  193. title: '数量',
  194. key: 'operNumber',
  195. width: '5%',
  196. type: FormTypes.inputNumber,
  197. validateRules: [{ required: true, message: '${title}不能为空' }],
  198. },
  199. { title: '单价', key: 'unitPrice', width: '5%', type: FormTypes.inputNumber },
  200. { title: '金额', key: 'allPrice', width: '5%', type: FormTypes.inputNumber },
  201. { title: '备注', key: 'remark', width: '5%', type: FormTypes.input },
  202. ],
  203. },
  204. confirmLoading: false,
  205. validatorRules: {
  206. operTime: {
  207. rules: [{ required: true, message: '请输入单据日期!' }],
  208. },
  209. type: {
  210. rules: [{ required: true, message: '请选择类型!' }],
  211. },
  212. },
  213. url: {
  214. add: '/depotHead/addDepotHeadAndDetail',
  215. edit: '/depotHead/updateDepotHeadAndDetail',
  216. detailList: '/depotItem/getDetailList',
  217. },
  218. }
  219. },
  220. created() {},
  221. methods: {
  222. //调用完edit()方法之后会自动调用此方法
  223. editAfter() {
  224. this.billStatus = '0'
  225. this.changeColumnHide()
  226. if (this.action === 'add') {
  227. this.addInit(this.prefixNo)
  228. this.fileList = []
  229. } else {
  230. this.model.operTime = this.model.operTimeStr
  231. this.fileList = this.model.fileName
  232. this.$nextTick(() => {
  233. this.form.setFieldsValue(
  234. pick(
  235. this.model,
  236. 'organId',
  237. 'operTime',
  238. 'number',
  239. 'remark',
  240. 'discount',
  241. 'discountMoney',
  242. 'discountLastMoney',
  243. 'otherMoney',
  244. 'accountId',
  245. 'changeAmount'
  246. )
  247. )
  248. })
  249. // 加载子表数据
  250. let params = {
  251. headerId: this.model.id,
  252. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  253. linkType: 'basic',
  254. }
  255. let url = this.readOnly ? this.url.detailList : this.url.detailList
  256. this.requestSubTableData(url, params, this.materialTable)
  257. }
  258. //复制新增单据-初始化单号和日期
  259. if (this.action === 'copyAdd') {
  260. this.model.id = ''
  261. this.model.tenantId = ''
  262. this.copyAddInit(this.prefixNo)
  263. }
  264. this.initSystemConfig()
  265. this.initDepot()
  266. this.initPlatform()
  267. this.initQuickBtn()
  268. },
  269. //提交单据时整理成formData
  270. classifyIntoFormData(allValues) {
  271. let totalPrice = 0
  272. let billMain = Object.assign(this.model, allValues.formValue)
  273. let detailArr = allValues.tablesValue[0].values
  274. billMain.type = '其它'
  275. billMain.subType = '拆卸单'
  276. for (let item of detailArr) {
  277. totalPrice += item.allPrice - 0
  278. }
  279. billMain.totalPrice = totalPrice
  280. if (this.fileList && this.fileList.length > 0) {
  281. billMain.fileName = this.fileList
  282. } else {
  283. billMain.fileName = ''
  284. }
  285. if (this.model.id) {
  286. billMain.id = this.model.id
  287. }
  288. billMain.status = this.billStatus
  289. return {
  290. info: JSON.stringify(billMain),
  291. rows: JSON.stringify(detailArr),
  292. }
  293. },
  294. onAdded(event) {
  295. const { row, target } = event
  296. getAction('/depot/findDepotByCurrentUser').then((res) => {
  297. if (res.code === 200) {
  298. let arr = res.data
  299. for (let i = 0; i < arr.length; i++) {
  300. if (arr[i].isDefault) {
  301. target.setValues([{ rowKey: row.id, values: { depotId: arr[i].id + '' } }])
  302. }
  303. }
  304. }
  305. })
  306. if (target.rows.length >= 2) {
  307. target.setValues([{ rowKey: row.id, values: { mType: '普通子件' } }])
  308. } else {
  309. target.setValues([{ rowKey: row.id, values: { mType: '组合件' } }])
  310. }
  311. },
  312. },
  313. }
  314. </script>
  315. <style scoped></style>