OtherInModal.vue 20 KB

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