OtherOutModal.vue 20 KB

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