OtherInModal.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. <a-select
  30. placeholder="请选择供应商"
  31. v-decorator="['organId']"
  32. :disabled="!rowCanEdit"
  33. :dropdownMatchSelectWidth="false"
  34. showSearch
  35. optionFilterProp="children"
  36. >
  37. <div slot="dropdownRender" slot-scope="menu">
  38. <v-nodes :vnodes="menu" />
  39. <a-divider style="margin: 4px 0" />
  40. <div
  41. v-if="quickBtn.vendor"
  42. style="padding: 4px 8px; cursor: pointer"
  43. @mousedown="(e) => e.preventDefault()"
  44. @click="addSupplier"
  45. >
  46. <a-icon type="plus" /> 新增供应商
  47. </div>
  48. </div>
  49. <a-select-option v-for="(item, index) in supList" :key="index" :value="item.id">
  50. {{ item.supplier }}
  51. </a-select-option>
  52. </a-select>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :lg="6" :md="12" :sm="24">
  56. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  57. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  58. </a-form-item>
  59. </a-col>
  60. <a-col :lg="6" :md="12" :sm="24">
  61. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据编号">
  62. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  63. </a-form-item>
  64. </a-col>
  65. <a-col :lg="6" :md="12" :sm="24">
  66. <a-form-item
  67. v-if="inOutManageFlag && !model.billType"
  68. :labelCol="labelCol"
  69. :wrapperCol="wrapperCol"
  70. label="关联单据"
  71. >
  72. <a-input-search
  73. placeholder="请选择待入库单据"
  74. v-decorator="['linkNumber']"
  75. @search="onSearchLinkNumber"
  76. :readOnly="true"
  77. />
  78. </a-form-item>
  79. </a-col>
  80. </a-row>
  81. <j-editable-table
  82. id="billModal"
  83. :ref="refKeys[0]"
  84. :loading="materialTable.loading"
  85. :columns="materialTable.columns"
  86. :dataSource="materialTable.dataSource"
  87. :minWidth="minWidth"
  88. :maxHeight="300"
  89. :rowNumber="false"
  90. :rowSelection="rowCanEdit"
  91. :actionButton="rowCanEdit"
  92. :dragSortAndNumber="rowCanEdit"
  93. @valueChange="onValueChange"
  94. @added="onAdded"
  95. @deleted="onDeleted"
  96. >
  97. <template #buttonAfter>
  98. <a-row
  99. v-if="rowCanEdit"
  100. :gutter="24"
  101. style="float: left"
  102. data-step="4"
  103. data-title="扫码录入"
  104. data-intro="此功能支持扫码枪扫描商品条码进行录入"
  105. >
  106. <a-col v-if="scanStatus" :md="6" :sm="24">
  107. <a-button @click="scanEnter">扫码录入</a-button>
  108. </a-col>
  109. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 8px 0 12px">
  110. <a-input
  111. placeholder="请扫描商品条码并回车"
  112. v-model="scanBarCode"
  113. @pressEnter="scanPressEnter"
  114. ref="scanBarCode"
  115. />
  116. </a-col>
  117. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 12px 0 0">
  118. <a-button @click="stopScan">收起扫码</a-button>
  119. </a-col>
  120. </a-row>
  121. <a-row v-if="rowCanEdit" :gutter="24" style="float: left; padding-bottom: 5px; padding-left: 20px">
  122. <a-button icon="import" @click="onImport(prefixNo)">导入明细</a-button>
  123. </a-row>
  124. </template>
  125. <template #depotBatchSet>
  126. <a-icon type="down" @click="handleBatchSetDepot" />
  127. </template>
  128. <template #depotAdd>
  129. <a-divider v-if="quickBtn.depot" style="margin: 4px 0" />
  130. <div v-if="quickBtn.depot" style="padding: 4px 8px; cursor: pointer" @click="addDepot">
  131. <a-icon type="plus" /> 新增仓库
  132. </div>
  133. </template>
  134. </j-editable-table>
  135. <a-row class="form-row" :gutter="24">
  136. <a-col :lg="24" :md="24" :sm="24">
  137. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  138. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  139. </a-form-item>
  140. </a-col>
  141. </a-row>
  142. <a-row class="form-row" :gutter="24">
  143. <a-col :lg="6" :md="12" :sm="24">
  144. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="附件">
  145. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  146. </a-form-item>
  147. </a-col>
  148. </a-row>
  149. <a-row class="form-row" :gutter="24">
  150. <a-col :lg="6" :md="12" :sm="24">
  151. <a-form-item
  152. :labelCol="labelCol"
  153. :wrapperCol="wrapperCol"
  154. label="凭证图片"
  155. data-step="11"
  156. data-title="附件"
  157. data-intro="可以上传与单据相关的图片、文档,支持多个文件"
  158. >
  159. <j-image-upload v-model="imageList" bizPath="material" text="上传图片" isMultiple></j-image-upload>
  160. </a-form-item>
  161. </a-col>
  162. </a-row>
  163. </a-form>
  164. </a-spin>
  165. <vendor-modal ref="vendorModalForm" @ok="vendorModalFormOk"></vendor-modal>
  166. <depot-modal ref="depotModalForm" @ok="depotModalFormOk"></depot-modal>
  167. <batch-set-depot ref="batchSetDepotModalForm" @ok="batchSetDepotModalFormOk"></batch-set-depot>
  168. <import-item-modal ref="importItemModalForm" @ok="importItemModalFormOk"></import-item-modal>
  169. <wait-bill-list ref="waitBillList" @ok="waitBillListOk"></wait-bill-list>
  170. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  171. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  172. </j-modal>
  173. </template>
  174. <script>
  175. import pick from 'lodash.pick'
  176. import VendorModal from '../../system/modules/VendorModal'
  177. import DepotModal from '../../system/modules/DepotModal'
  178. import BatchSetDepot from '../dialog/BatchSetDepot'
  179. import ImportItemModal from '../dialog/ImportItemModal'
  180. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  181. import BillPrintIframe from '../dialog/BillPrintIframe'
  182. import { FormTypes } from '@/utils/JEditableTableUtil'
  183. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  184. import { BillModalMixin } from '../mixins/BillModalMixin'
  185. import { getMpListShort } from '@/utils/util'
  186. import JUpload from '@/components/jeecg/JUpload'
  187. import JDate from '@/components/jeecg/JDate'
  188. import Vue from 'vue'
  189. import WaitBillList from '../dialog/WaitBillList'
  190. import JImageUpload from '@/components/jeecg/JImageUpload.vue'
  191. export default {
  192. name: 'OtherInModal',
  193. mixins: [JEditableTableMixin, BillModalMixin],
  194. components: {
  195. VendorModal,
  196. DepotModal,
  197. BatchSetDepot,
  198. ImportItemModal,
  199. WaitBillList,
  200. WorkflowIframe,
  201. BillPrintIframe,
  202. JUpload,
  203. JImageUpload,
  204. JDate,
  205. VNodes: {
  206. functional: true,
  207. render: (h, ctx) => ctx.props.vnodes,
  208. },
  209. },
  210. data() {
  211. return {
  212. title: '操作',
  213. width: '1600px',
  214. moreStatus: false,
  215. // 新增时子表默认添加几行空数据
  216. addDefaultRowNum: 1,
  217. visible: false,
  218. operTimeStr: '',
  219. prefixNo: 'QTRK',
  220. fileList: [],
  221. imageList: [],
  222. rowCanEdit: true,
  223. //出入库管理开关,适合独立仓管场景
  224. inOutManageFlag: false,
  225. model: {},
  226. labelCol: {
  227. xs: { span: 24 },
  228. sm: { span: 8 },
  229. },
  230. wrapperCol: {
  231. xs: { span: 24 },
  232. sm: { span: 16 },
  233. },
  234. refKeys: ['materialDataTable'],
  235. activeKey: 'materialDataTable',
  236. materialTable: {
  237. loading: false,
  238. dataSource: [],
  239. columns: [
  240. // {
  241. // title: '仓库名称',
  242. // key: 'depotId',
  243. // width: '8%',
  244. // type: FormTypes.select,
  245. // placeholder: '请选择${title}',
  246. // options: [],
  247. // allowSearch: true,
  248. // disabled: true,
  249. // validateRules: [{ required: true, message: '${title}不能为空' }],
  250. // },
  251. // { title: '批次号', key: 'batchNumber', width: '9%', type: FormTypes.normal },
  252. {
  253. title: '批次号',
  254. key: 'batchNumber',
  255. width: '12%',
  256. type: FormTypes.popupJsh,
  257. kind: 'material',
  258. multi: true,
  259. validateRules: [{ required: true, message: '${title}不能为空' }],
  260. },
  261. { title: '名称', key: 'name', width: '10%', type: FormTypes.normal },
  262. { title: '规格', key: 'standard', width: '9%', type: FormTypes.normal },
  263. { title: '生产日期', key: 'productionDate', width: '9%', type: FormTypes.normal },
  264. { title: '保质期', key: 'expiryNum', width: '6%', type: FormTypes.normal },
  265. { title: '商品条码', key: 'barCode', width: '9%', type: FormTypes.normal },
  266. { title: '仓库名', key: 'depotName', width: '9%', type: FormTypes.normal },
  267. { title: '仓库货架', key: 'position', width: '9%', type: FormTypes.normal },
  268. { title: '包装规格', key: 'unitName', width: '9%', type: FormTypes.input },
  269. { title: '型号', key: 'model', width: '9%', type: FormTypes.normal },
  270. { title: '颜色', key: 'color', width: '5%', type: FormTypes.normal },
  271. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  272. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  273. { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
  274. { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
  275. { title: '单位', key: 'unit', width: '4%', type: FormTypes.select },
  276. { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
  277. { title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input },
  278. { title: '有效期', key: 'expirationDate', width: '7%', type: FormTypes.date },
  279. { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },
  280. { title: '原数量', key: 'preNumber', width: '4%', type: FormTypes.normal },
  281. { title: '已入库', key: 'finishNumber', width: '4%', type: FormTypes.normal },
  282. {
  283. title: '数量',
  284. key: 'operNumber',
  285. width: '5%',
  286. type: FormTypes.inputNumber,
  287. statistics: true,
  288. validateRules: [{ required: true, message: '${title}不能为空' }],
  289. },
  290. { title: '单价', key: 'unitPrice', width: '5%', type: FormTypes.inputNumber },
  291. { title: '金额', key: 'allPrice', width: '5%', type: FormTypes.inputNumber, statistics: true },
  292. {
  293. title: '实际入库数量',
  294. key: 'actualQuantityInStorage',
  295. width: '9%',
  296. type: FormTypes.inputNumber,
  297. validateRules: [{ required: true, message: '实际入库数量不能为空' }],
  298. },
  299. { title: '入库差异', key: 'warehousingVariance', width: '9%', type: FormTypes.input },
  300. { title: '入库差异原因', key: 'reasonOfDifference', width: '9%', type: FormTypes.input },
  301. {
  302. title: '入库人',
  303. key: 'warehousingUser',
  304. width: '9%',
  305. type: FormTypes.input,
  306. validateRules: [{ required: true, message: '入库人不能为空' }],
  307. },
  308. { title: '入库时间', key: 'warehousingTime', width: '9%', type: FormTypes.date },
  309. { title: '备注', key: 'remark', width: '5%', type: FormTypes.input },
  310. { title: '关联id', key: 'linkId', width: '5%', type: FormTypes.hidden },
  311. ],
  312. },
  313. confirmLoading: false,
  314. validatorRules: {
  315. operTime: {
  316. rules: [{ required: true, message: '请输入单据日期!' }],
  317. },
  318. type: {
  319. rules: [{ required: true, message: '请选择类型!' }],
  320. },
  321. },
  322. url: {
  323. add: '/depotHead/addDepotHeadAndDetail',
  324. edit: '/depotHead/updateDepotHeadAndDetail',
  325. detailList: '/depotItem/getDetailList',
  326. },
  327. }
  328. },
  329. created() {},
  330. methods: {
  331. //调用完edit()方法之后会自动调用此方法
  332. editAfter() {
  333. this.billStatus = '0'
  334. this.currentSelectDepotId = ''
  335. this.rowCanEdit = true
  336. this.materialTable.columns[0].type = FormTypes.popupJsh
  337. this.changeColumnHide()
  338. this.changeFormTypes(this.materialTable.columns, 'snList', 0)
  339. // this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
  340. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
  341. this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
  342. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
  343. if (this.action === 'add') {
  344. this.addInit(this.prefixNo)
  345. this.fileList = []
  346. this.imageList = []
  347. } else {
  348. if (this.model.linkNumber) {
  349. this.rowCanEdit = false
  350. this.materialTable.columns[1].type = FormTypes.normal
  351. }
  352. this.model.operTime = this.model.operTimeStr
  353. this.fileList = this.model.fileName
  354. this.imageList = this.model.voucherPicture
  355. this.$nextTick(() => {
  356. this.form.setFieldsValue(
  357. pick(
  358. this.model,
  359. 'organId',
  360. 'operTime',
  361. 'number',
  362. 'linkNumber',
  363. 'remark',
  364. 'discount',
  365. 'discountMoney',
  366. 'discountLastMoney',
  367. 'otherMoney',
  368. 'accountId',
  369. 'changeAmount'
  370. )
  371. )
  372. })
  373. // 加载子表数据
  374. let params = {
  375. headerId: this.model.id,
  376. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  377. linkType: 'basic',
  378. }
  379. let url = this.readOnly ? this.url.detailList : this.url.detailList
  380. this.requestSubTableData(url, params, this.materialTable)
  381. }
  382. //复制新增单据-初始化单号和日期
  383. if (this.action === 'copyAdd') {
  384. this.model.id = ''
  385. this.model.tenantId = ''
  386. this.copyAddInit(this.prefixNo)
  387. }
  388. this.initSystemConfig()
  389. this.initSupplier(0)
  390. this.initDepot()
  391. this.initPlatform()
  392. this.initQuickBtn()
  393. },
  394. //提交单据时整理成formData
  395. classifyIntoFormData(allValues) {
  396. let totalPrice = 0
  397. let billMain = Object.assign(this.model, allValues.formValue)
  398. let detailArr = allValues.tablesValue[0].values
  399. billMain.type = '入库'
  400. billMain.subType = '其它'
  401. for (let item of detailArr) {
  402. totalPrice += item.allPrice - 0
  403. }
  404. billMain.totalPrice = 0 - totalPrice
  405. if (this.fileList && this.fileList.length > 0) {
  406. billMain.fileName = this.fileList
  407. } else {
  408. billMain.fileName = ''
  409. }
  410. if (this.imageList && this.imageList.length > 0) {
  411. billMain.voucherPicture = this.imageList
  412. } else {
  413. billMain.voucherPicture = ''
  414. }
  415. if (this.model.id) {
  416. billMain.id = this.model.id
  417. }
  418. billMain.status = this.billStatus
  419. return {
  420. info: JSON.stringify(billMain),
  421. rows: JSON.stringify(detailArr),
  422. }
  423. },
  424. onSearchLinkNumber() {
  425. this.$refs.waitBillList.show('入库', '采购,销售退货', '1,3')
  426. this.$refs.waitBillList.title = '请选择采购入库或销售退货'
  427. },
  428. waitBillListOk(selectBillDetailRows, linkNumber, remark) {
  429. this.rowCanEdit = false
  430. this.materialTable.columns[1].type = FormTypes.normal
  431. this.changeFormTypes(this.materialTable.columns, 'preNumber', 1)
  432. this.changeFormTypes(this.materialTable.columns, 'finishNumber', 1)
  433. if (selectBillDetailRows && selectBillDetailRows.length > 0) {
  434. let listEx = []
  435. for (let j = 0; j < selectBillDetailRows.length; j++) {
  436. let info = selectBillDetailRows[j]
  437. if (info.finishNumber > 0) {
  438. info.operNumber = info.preNumber - info.finishNumber
  439. }
  440. info.unitPrice = 0
  441. info.allPrice = 0
  442. info.linkId = info.id
  443. listEx.push(info)
  444. this.changeColumnShow(info)
  445. }
  446. this.materialTable.dataSource = listEx
  447. this.$nextTick(() => {
  448. this.form.setFieldsValue({
  449. linkNumber: linkNumber,
  450. remark: remark,
  451. })
  452. })
  453. }
  454. },
  455. },
  456. }
  457. </script>
  458. <style scoped></style>