OtherInModal.vue 19 KB

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