PurchaseApplyModal.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. switchHelp
  12. switchFullscreen
  13. @cancel="handleCancel"
  14. :id="prefixNo"
  15. style="top: 20px; height: 95%"
  16. >
  17. <template slot="footer">
  18. <a-button @click="handleCancel">取消</a-button>
  19. <a-button v-if="billPrintFlag && isShowPrintBtn" @click="handlePrint('请购单')">三联打印预览</a-button>
  20. <a-button v-if="checkFlag && isCanCheck" :loading="confirmLoading" @click="handleOkAndCheck">保存并审核</a-button>
  21. <a-button type="primary" :loading="confirmLoading" @click="handleOk">保存(Ctrl+S)</a-button>
  22. <!--发起多级审核-->
  23. <a-button v-if="!checkFlag" @click="handleWorkflow()" type="primary">提交流程</a-button>
  24. </template>
  25. <a-spin :spinning="confirmLoading">
  26. <a-form :form="form">
  27. <a-row class="form-row" :gutter="24">
  28. <a-col :lg="6" :md="12" :sm="24">
  29. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="单据日期">
  30. <j-date v-decorator="['operTime', validatorRules.operTime]" :show-time="true" />
  31. </a-form-item>
  32. </a-col>
  33. <a-col :lg="6" :md="12" :sm="24">
  34. <a-form-item
  35. :labelCol="labelCol"
  36. :wrapperCol="wrapperCol"
  37. label="单据编号"
  38. data-step="2"
  39. data-title="单据编号"
  40. data-intro="单据编号自动生成、自动累加、开头是单据类型的首字母缩写,累加的规则是每次打开页面会自动占用一个新的编号"
  41. >
  42. <a-input placeholder="请输入单据编号" v-decorator.trim="['number']" />
  43. </a-form-item>
  44. </a-col>
  45. <a-col :lg="6" :md="12" :sm="24"> </a-col>
  46. <a-col :lg="6" :md="12" :sm="24"> </a-col>
  47. </a-row>
  48. <j-editable-table
  49. id="billModal"
  50. :ref="refKeys[0]"
  51. :loading="materialTable.loading"
  52. :columns="materialTable.columns"
  53. :dataSource="materialTable.dataSource"
  54. :minWidth="minWidth"
  55. :maxHeight="300"
  56. :rowNumber="false"
  57. :rowSelection="rowCanEdit"
  58. :actionButton="rowCanEdit"
  59. :dragSortAndNumber="rowCanEdit"
  60. @valueChange="onValueChange"
  61. @added="onAdded"
  62. @deleted="onDeleted"
  63. >
  64. <template #buttonAfter>
  65. <a-row
  66. v-if="rowCanEdit"
  67. :gutter="24"
  68. style="float: left; padding-bottom: 5px"
  69. data-step="4"
  70. data-title="扫码录入"
  71. data-intro="此功能支持扫码枪扫描商品条码进行录入"
  72. >
  73. <a-col v-if="scanStatus" :md="6" :sm="24">
  74. <a-button @click="scanEnter">扫码录入</a-button>
  75. </a-col>
  76. <a-col v-if="!scanStatus" :md="16" :sm="24" style="padding: 0 8px 0 12px">
  77. <a-input
  78. placeholder="请扫描商品条码并回车"
  79. v-model="scanBarCode"
  80. @pressEnter="scanPressEnter"
  81. ref="scanBarCode"
  82. />
  83. </a-col>
  84. <a-col v-if="!scanStatus" :md="6" :sm="24" style="padding: 0px 12px 0 0">
  85. <a-button @click="stopScan">收起扫码</a-button>
  86. </a-col>
  87. </a-row>
  88. <a-row :gutter="24" style="float: left; padding-bottom: 5px">
  89. <a-col :md="24" :sm="24">
  90. <a-button style="margin-left: 8px" @click="handleHistoryBillList"
  91. ><a-icon type="history" />历史单据</a-button
  92. >
  93. </a-col>
  94. </a-row>
  95. <a-row v-if="rowCanEdit" :gutter="24" style="float: left; padding-bottom: 5px; padding-left: 20px">
  96. <a-button icon="import" @click="onImport(prefixNo)">导入明细</a-button>
  97. </a-row>
  98. </template>
  99. </j-editable-table>
  100. <a-row class="form-row" :gutter="24">
  101. <a-col :lg="24" :md="24" :sm="24">
  102. <a-form-item :labelCol="labelCol" :wrapperCol="{ xs: { span: 24 }, sm: { span: 24 } }" label="">
  103. <a-textarea :rows="1" placeholder="请输入备注" v-decorator="['remark']" style="margin-top: 8px" />
  104. </a-form-item>
  105. </a-col>
  106. </a-row>
  107. <a-row class="form-row" :gutter="24">
  108. <a-col :lg="6" :md="12" :sm="24">
  109. <a-form-item
  110. :labelCol="labelCol"
  111. :wrapperCol="wrapperCol"
  112. label="附件"
  113. data-step="10"
  114. data-title="附件"
  115. data-intro="可以上传与单据相关的图片、文档,支持多个文件"
  116. >
  117. <j-upload v-model="fileList" bizPath="bill"></j-upload>
  118. </a-form-item>
  119. </a-col>
  120. </a-row>
  121. </a-form>
  122. </a-spin>
  123. <import-item-modal ref="importItemModalForm" @ok="importItemModalFormOk" exportTitle="清购单导入模版[下载]"></import-item-modal>
  124. <history-bill-list ref="historyBillListModalForm"></history-bill-list>
  125. <workflow-iframe ref="modalWorkflow" @ok="workflowModalFormOk"></workflow-iframe>
  126. <bill-print-iframe ref="modalPrint"></bill-print-iframe>
  127. </j-modal>
  128. </template>
  129. <script>
  130. import pick from 'lodash.pick'
  131. import ImportItemModal from '../dialog/ImportItemModal'
  132. import HistoryBillList from '../dialog/HistoryBillList'
  133. import WorkflowIframe from '@/components/tools/WorkflowIframe'
  134. import BillPrintIframe from '../dialog/BillPrintIframe'
  135. import { FormTypes } from '@/utils/JEditableTableUtil'
  136. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  137. import { BillModalMixin } from '../mixins/BillModalMixin'
  138. import { getMpListShort, changeListFmtMinus, handleIntroJs } from '@/utils/util'
  139. import JUpload from '@/components/jeecg/JUpload'
  140. import JDate from '@/components/jeecg/JDate'
  141. import Vue from 'vue'
  142. export default {
  143. name: 'PurchaseApplyModal',
  144. mixins: [JEditableTableMixin, BillModalMixin],
  145. components: {
  146. ImportItemModal,
  147. HistoryBillList,
  148. WorkflowIframe,
  149. BillPrintIframe,
  150. JUpload,
  151. JDate,
  152. VNodes: {
  153. functional: true,
  154. render: (h, ctx) => ctx.props.vnodes,
  155. },
  156. },
  157. data() {
  158. return {
  159. title: '操作',
  160. width: '1600px',
  161. moreStatus: false,
  162. // 新增时子表默认添加几行空数据
  163. addDefaultRowNum: 1,
  164. visible: false,
  165. supList: [],
  166. depotList: [],
  167. operTimeStr: '',
  168. prefixNo: 'QGD',
  169. fileList: [],
  170. rowCanEdit: true,
  171. //以销定购的场景开关
  172. purchaseBySaleFlag: false,
  173. model: {},
  174. labelCol: {
  175. xs: { span: 24 },
  176. sm: { span: 8 },
  177. },
  178. wrapperCol: {
  179. xs: { span: 24 },
  180. sm: { span: 16 },
  181. },
  182. refKeys: ['materialDataTable'],
  183. tableKeys: ['materialDataTable'],
  184. activeKey: 'materialDataTable',
  185. materialTable: {
  186. loading: false,
  187. dataSource: [],
  188. columns: [
  189. { title: '', key: 'hiddenKey', width: '1%', type: FormTypes.hidden },
  190. {
  191. title: '条码',
  192. key: 'barCode',
  193. width: '12%',
  194. type: FormTypes.popupJsh,
  195. kind: 'material',
  196. multi: true,
  197. validateRules: [{ required: true, message: '${title}不能为空' }],
  198. },
  199. { title: '名称', key: 'name', width: '10%', type: FormTypes.normal },
  200. { title: '规格', key: 'standard', width: '9%', type: FormTypes.normal },
  201. { title: '型号', key: 'model', width: '9%', type: FormTypes.normal },
  202. { title: '颜色', key: 'color', width: '6%', type: FormTypes.normal },
  203. { title: '品牌', key: 'brand', width: '6%', type: FormTypes.normal },
  204. { title: '制造商', key: 'mfrs', width: '6%', type: FormTypes.normal },
  205. { title: '扩展信息', key: 'materialOther', width: '6%', type: FormTypes.normal },
  206. { title: '单位', key: 'unit', width: '6%', type: FormTypes.normal },
  207. { title: '多属性', key: 'sku', width: '10%', type: FormTypes.normal },
  208. {
  209. title: '数量',
  210. key: 'operNumber',
  211. width: '6%',
  212. type: FormTypes.inputNumber,
  213. statistics: true,
  214. validateRules: [{ required: true, message: '${title}不能为空' }],
  215. },
  216. { title: '备注', key: 'remark', width: '8%', type: FormTypes.input },
  217. ],
  218. },
  219. confirmLoading: false,
  220. validatorRules: {
  221. operTime: {
  222. rules: [{ required: true, message: '请输入单据日期!' }],
  223. },
  224. organId: {
  225. rules: [{ required: true, message: '请选择供应商!' }],
  226. },
  227. },
  228. url: {
  229. add: '/depotHead/addDepotHeadAndDetail',
  230. edit: '/depotHead/updateDepotHeadAndDetail',
  231. detailList: '/depotItem/getDetailList',
  232. importExcelUrl: '/depotItem/importItemExcel',
  233. },
  234. }
  235. },
  236. created() {},
  237. methods: {
  238. //调用完edit()方法之后会自动调用此方法
  239. editAfter() {
  240. this.billStatus = '0'
  241. this.rowCanEdit = true
  242. this.changeColumnHide()
  243. if (this.action === 'add') {
  244. this.addInit(this.prefixNo)
  245. this.fileList = []
  246. this.$nextTick(() => {
  247. handleIntroJs(this.prefixNo, 1)
  248. })
  249. } else {
  250. this.model.operTime = this.model.operTimeStr
  251. if (this.model.accountId == null && this.model.accountIdList) {
  252. this.model.accountId = 0
  253. this.manyAccountBtnStatus = true
  254. this.accountIdList = this.model.accountIdList
  255. this.accountMoneyList = this.model.accountMoneyList
  256. } else {
  257. this.manyAccountBtnStatus = false
  258. }
  259. this.fileList = this.model.fileName
  260. this.$nextTick(() => {
  261. this.form.setFieldsValue(pick(this.model, 'operTime', 'number', 'remark'))
  262. })
  263. // 加载子表数据
  264. let params = {
  265. headerId: this.model.id,
  266. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  267. linkType: 'basic',
  268. }
  269. let url = this.readOnly ? this.url.detailList : this.url.detailList
  270. this.requestSubTableData(url, params, this.materialTable)
  271. }
  272. //复制新增单据-初始化单号和日期
  273. if (this.action === 'copyAdd') {
  274. this.model.id = ''
  275. this.model.tenantId = ''
  276. this.copyAddInit(this.prefixNo)
  277. }
  278. this.initSystemConfig()
  279. this.initPlatform()
  280. this.initQuickBtn()
  281. },
  282. /** 整理成formData */
  283. classifyIntoFormData(allValues) {
  284. let totalPrice = 0
  285. let billMain = Object.assign(this.model, allValues.formValue)
  286. let detailArr = allValues.tablesValue[0].values
  287. billMain.type = '其它'
  288. billMain.subType = '请购单'
  289. for (let item of detailArr) {
  290. totalPrice += item.allPrice - 0
  291. }
  292. billMain.totalPrice = 0 - totalPrice
  293. if (this.fileList && this.fileList.length > 0) {
  294. billMain.fileName = this.fileList
  295. } else {
  296. billMain.fileName = ''
  297. }
  298. if (this.model.id) {
  299. billMain.id = this.model.id
  300. }
  301. billMain.status = this.billStatus
  302. return {
  303. info: JSON.stringify(billMain),
  304. rows: JSON.stringify(detailArr),
  305. }
  306. },
  307. handleHistoryBillList() {
  308. let organId = this.form.getFieldValue('organId')
  309. this.$refs.historyBillListModalForm.show('其它', '请购单', '', organId)
  310. this.$refs.historyBillListModalForm.disableSubmit = false
  311. },
  312. },
  313. }
  314. </script>
  315. <style scoped></style>