OtherOutModal.vue 20 KB

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