PurchaseOrderFormForm.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <a-spin :spinning="loading">
  3. <JFormContainer :disabled="disabled">
  4. <template #detail>
  5. <a-form v-bind="formItemLayout" name="SaleOrderForm" ref="formRef">
  6. <a-row>
  7. <a-col :span="12">
  8. <a-form-item label="订单编号(bill code)" v-bind="validateInfos.billCode" id="SaleOrderForm-billCode" name="billCode">
  9. <a-input v-model:value="formData.billCode" placeholder="订单编号(bill code)" disabled></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :span="12">
  13. <a-form-item label="单据日期(bill date)" v-bind="validateInfos.billDate" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-billDate" name="billDate">
  14. <a-date-picker placeholder="请选择单据日期(bill date)" v-model:value="formData.billDate" value-format="YYYY-MM-DD" style="width: 100%" allow-clear />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="12">
  18. <a-form-item label="项目(project)" v-bind="validateInfos.projectName" id="SaleOrderForm-projectName" name="projectName">
  19. <a-input-search v-model:value="formData.projectName" placeholder="请输入项目(project)" :disabled="notAllowEdit" allow-clear enter-button="Search" @search="onSearchProject"></a-input-search>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :span="12">
  23. <a-form-item label="供应商(supplier)" v-bind="validateInfos.supplier" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-supplier" name="supplier">
  24. <a-input v-model:value="formData.supplierName" placeholder="请选择" allow-clear ></a-input>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="12">
  28. <a-form-item label="优先级(priority)" v-bind="validateInfos.priority" id="SaleOrderForm-priority" name="priority">
  29. <JDictSelectTag v-model:value="formData.priority" placeholder="请选择" dictCode="priority" disabled/>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :span="12">
  33. <a-form-item label="产品分类(production class)" v-bind="validateInfos.productionClass" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-productionClass" name="productionClass">
  34. <a-input v-model:value="formData.productionClass" placeholder="请输入" allow-clear disabled ></a-input>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :span="12">
  38. <a-form-item label="机型(model)" v-bind="validateInfos.model" id="SaleOrderForm-model" name="model">
  39. <JDictSelectTag v-model:value="formData.model" placeholder="请选择" dictCode="model_typer" disabled />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :span="12">
  43. <a-form-item label="厂家(maker)" v-bind="validateInfos.maker" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-maker" name="maker">
  44. <a-input v-model:value="formData.maker" placeholder="请输入厂家(maker)" allow-clear disabled></a-input>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="12">
  48. <a-form-item label="贸易条款(trade term)" v-bind="validateInfos.tradeTerms" id="SaleOrderForm-tradeTerms" name="tradeTerms">
  49. <JDictSelectTag v-model:value="formData.tradeTerms" placeholder="请选择" dictCode="delivery_terms"/>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :span="12">
  53. <a-form-item label="包装要求(package requirement)" v-bind="validateInfos.packagebRequirement" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-packagebRequirement" name="packagebRequirement">
  54. <a-input v-model:value="formData.packagebRequirement" placeholder="请输入包装要求(package requirement)" allow-clear ></a-input>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :span="12">
  58. <a-form-item label="是否出口(export)" v-bind="validateInfos.isExport" id="SaleOrderForm-isExport" name="isExport">
  59. <JDictSelectTag v-model:value="formData.isExport" placeholder="请选择" dictCode="yes_or_no" />
  60. </a-form-item>
  61. </a-col>
  62. <a-col :span="12">
  63. <a-form-item label="收件人(recipient)" v-bind="validateInfos.recipient" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-recipient" name="recipient">
  64. <a-input v-model:value="formData.recipient" placeholder="请选择" />
  65. </a-form-item>
  66. </a-col>
  67. <a-col :span="12">
  68. <a-form-item label="收件人电话(recipient tel)" v-bind="validateInfos.recipientTel" id="SaleOrderForm-recipientTel" name="recipientTel">
  69. <a-input v-model:value="formData.recipientTel" placeholder="请选择" />
  70. </a-form-item>
  71. </a-col>
  72. <a-col :span="12">
  73. <a-form-item label="收件人地址(recipient address)" v-bind="validateInfos.recipientAddress" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-recipientAddress" name="recipientAddress">
  74. <a-input v-model:value="formData.recipientAddress" placeholder="请选择" />
  75. </a-form-item>
  76. </a-col>
  77. <a-col :span="12">
  78. <a-form-item label="付款条件(payment terms)" v-bind="validateInfos.paymentTerms" id="SaleOrderForm-paymentTerms" name="paymentTerms">
  79. <JDictSelectTag v-model:value="formData.paymentTerms" placeholder="请选择" dictCode="payment_terms" />
  80. </a-form-item>
  81. </a-col>
  82. <a-col :span="12">
  83. <a-form-item label="发货方式(delivery)" v-bind="validateInfos.delivery" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-delivery" name="delivery">
  84. <JDictSelectTag v-model:value="formData.delivery" placeholder="请选择" dictCode="delivery_methods" />
  85. </a-form-item>
  86. </a-col>
  87. <a-col :span="12">
  88. <a-form-item label="质保期(warranty period)" v-bind="validateInfos.warrantyPeriod" id="SaleOrderForm-warrantyPeriod" name="warrantyPeriod">
  89. <a-input v-model:value="formData.warrantyPeriod" placeholder="请输入" style="width: 85%;margin-right: 1%;"/>月(month)
  90. </a-form-item>
  91. </a-col>
  92. <a-col :span="12">
  93. <a-form-item label="质保条款(warranty terms)" v-bind="validateInfos.warrantyTerms" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-warrantyTerms" name="warrantyTerms">
  94. <a-input v-model:value="formData.warrantyTerms" placeholder="请输入质保条款(warranty terms)" allow-clear ></a-input>
  95. </a-form-item>
  96. </a-col>
  97. <a-col :span="12">
  98. <a-form-item label="汇率(exchange rate)" v-bind="validateInfos.exchangeRate" id="SaleOrderForm-exchangeRate" name="exchangeRate">
  99. <a-input v-model:value="formData.exchangeRate" placeholder="请输入厂家(maker)" allow-clear ></a-input>
  100. </a-form-item>
  101. </a-col>
  102. <a-col :span="12">
  103. <a-form-item label="采购部门(purchase department)" v-bind="validateInfos.purchaseDepartment" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-purchaseDepartment" name="purchaseDepartment">
  104. <a-input v-model:value="formData.purchaseDepartment" placeholder="请输入" allow-clear disabled></a-input>
  105. </a-form-item>
  106. </a-col>
  107. <a-col :span="12">
  108. <a-form-item label="采购员(purchasesman)" v-bind="validateInfos.purchaseman" id="SaleOrderForm-purchaseman" name="purchaseman">
  109. <a-input v-model:value="formData.purchaseman" placeholder="请输入采购员(salesman)" allow-clear disabled ></a-input>
  110. </a-form-item>
  111. </a-col>
  112. <a-col :span="12">
  113. <a-form-item label="币种(currency)" v-bind="validateInfos.currency" :label-col="formItemLayout.labelCol1" :wrapper-col="formItemLayout.wrapperCol1" id="SaleOrderForm-currency" name="currency">
  114. <JDictSelectTag v-model:value="formData.currency" placeholder="请选择" dictCode="currency" />
  115. </a-form-item>
  116. </a-col>
  117. <a-col :span="12">
  118. <a-form-item label="备注(notes)" v-bind="validateInfos.notes" id="SaleOrderForm-notes" name="notes">
  119. <a-input v-model:value="formData.notes"></a-input>
  120. </a-form-item>
  121. </a-col>
  122. </a-row>
  123. </a-form>
  124. </template>
  125. </JFormContainer>
  126. <!-- 子表单区域 -->
  127. <a-tabs v-model:activeKey="activeKey" animated style=" padding: 24px;padding-top: 0px;">
  128. <a-tab-pane tab="采购订单 - 船明细(ship details)" key="PurOrderFormShipFormShip" :forceRender="true">
  129. <j-vxe-table
  130. :keep-source="true"
  131. resizable
  132. ref="PurOrderFormShipFormShipTableRef"
  133. :loading="PurOrderFormShipFormShipTable.loading"
  134. :columns="PurOrderFormShipFormShipTable.columns"
  135. :dataSource="PurOrderFormShipFormShipTable.dataSource"
  136. :height="340"
  137. :disabled="disabled"
  138. :rowNumber="true"
  139. :rowSelection="true"
  140. >
  141. <template #action="props" >
  142. <a @click="viewAccessory(props)">查看配件信息(view accessory information)</a>
  143. </template>
  144. </j-vxe-table>
  145. </a-tab-pane>
  146. <a-tab-pane tab="采购订单 - 产品明细(product details)" key="purOrderFormShipFormProduct" :forceRender="true">
  147. <a-button type="primary" style="margin-right: 1%;margin-bottom: 1%;" @click="selectSaleOrderList"> 选择销售订单(select saleorder)</a-button>
  148. <a-button type="primary" style="margin-right: 1%;margin-bottom: 1%;" @click="SelectSupplierQuotationList"> 选择报价单(select quotation)</a-button>
  149. <a-button type="primary" style="margin-right: 1%;margin-bottom: 1%;" @click="selectProductList"> 选择产品(select product)</a-button>
  150. <j-vxe-table
  151. :keep-source="true"
  152. resizable
  153. ref="purOrderFormShipFormProductTableRef"
  154. :loading="purOrderFormShipFormProductTable.loading"
  155. :columns="purOrderFormShipFormProductTable.columns"
  156. :dataSource="purOrderFormShipFormProductTable.dataSource"
  157. :height="340"
  158. :disabled="disabled"
  159. :rowNumber="true"
  160. :rowSelection="true"
  161. asyncRemove
  162. >
  163. <template #action="props">
  164. <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)">
  165. <a>删除(delete)</a>
  166. </a-popconfirm>
  167. </template>
  168. </j-vxe-table>
  169. </a-tab-pane>
  170. </a-tabs>
  171. <SelectPrpductModal ref="SelectPrpductModalRef" @selectProduct ='addProduct'></SelectPrpductModal>
  172. <SelectProjectModal ref="SelectProjectModalRef" @selectProject="addProject"></SelectProjectModal>
  173. <BaseShipArchiveAccessoriesModal ref="BaseShipArchiveAccessoriesModalRef"></BaseShipArchiveAccessoriesModal>
  174. <SelectSupplierQuotationModal ref="SelectSupplierQuotationModalRef" @selectSupplierQuotation="addFromQuotation"></SelectSupplierQuotationModal>
  175. <SelectSaleOrderModal ref="SelectSaleOrderModalRef" @selectSaleOrder="addFormSaleOrder"></SelectSaleOrderModal>
  176. </a-spin>
  177. </template>
  178. <script lang="ts">
  179. import { defineComponent, ref, reactive, computed, toRaw} from 'vue';
  180. import { defHttp } from '/@/utils/http/axios';
  181. import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
  182. import { queryPurOrderFormShipFormShippTable, queryPurOrderFormProductListByMainId, queryDataById, saveOrUpdate,queryVersonHistoryById,queryPurVersonFormShipListByMainId, queryPurVersonProductListByMainId} from '../PurchaseOrderyForm.api';
  183. import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  184. import {purchaseOrderShipColumns, purchaseOrderProductColumns} from '../PurchaseOrderForm.data';
  185. import SelectPrpductModal from '../../../publicComponents/SelectPrpductModal.vue';
  186. import SelectProjectModal from '../../../publicComponents/SelectProjectModal.vue';
  187. import SelectSaleOrderModal from '../../../publicComponents/SelectSaleOrderModal.vue';
  188. import SelectSupplierQuotationModal from '../../../publicComponents/SelectSupplierQuotationModal.vue';
  189. import BaseShipArchiveAccessoriesModal from '../../../publicComponents/BaseShipArchiveAccessoriesModal.vue';
  190. import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  191. import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  192. import { JDictSelectTag} from '/@/components/Form';
  193. import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  194. import { Form, message } from 'ant-design-vue';
  195. import { useUserStore } from '/@/store/modules/user';
  196. import moment from 'moment';
  197. const useForm = Form.useForm;
  198. export default defineComponent({
  199. name: "SaleOrderForm",
  200. components:{
  201. JVxeTable,
  202. JFormContainer,
  203. SelectPrpductModal,
  204. JUpload,
  205. JDictSelectTag,
  206. JSelectInput,
  207. SelectProjectModal,
  208. BaseShipArchiveAccessoriesModal,
  209. SelectSupplierQuotationModal,
  210. SelectSaleOrderModal
  211. },
  212. props:{
  213. formDisabled:{
  214. type: Boolean,
  215. default: false
  216. },
  217. formData: { type: Object, default: ()=>{} },
  218. formBpm: { type: Boolean, default: true }
  219. },
  220. emits:['success'],
  221. setup(props, {emit}) {
  222. const userStore = useUserStore();
  223. const loading = ref(false);
  224. const formRef = ref();
  225. const PurOrderFormShipFormShipTableRef = ref();
  226. const SelectPrpductModalRef = ref()
  227. const SelectProjectModalRef = ref()
  228. const BaseShipArchiveAccessoriesModalRef = ref();
  229. const SelectSupplierQuotationModalRef = ref();
  230. const SelectSaleOrderModalRef = ref();
  231. const PurOrderFormShipFormShipTable = reactive<Record<string, any>>({
  232. loading: false,
  233. columns: purchaseOrderShipColumns,
  234. dataSource: []
  235. });
  236. const purOrderFormShipFormProductTableRef = ref();
  237. const purOrderFormShipFormProductTable = reactive<Record<string, any>>({
  238. loading: false,
  239. columns: purchaseOrderProductColumns,
  240. dataSource: []
  241. });
  242. const activeKey = ref('PurOrderFormShipFormShip');
  243. var notAllowEdit = ref(false);
  244. const formData = reactive<Record<string, any>>({
  245. id: '',
  246. status: undefined,
  247. delFlag: undefined,
  248. sourceCode:'',
  249. sourceCode2:'',
  250. submit:undefined,
  251. billCode:'',
  252. billDate: moment(new Date()).format('YYYY-MM-DD'),
  253. project: '',
  254. projectName:'',
  255. supplier:"",
  256. supplierName:'',
  257. priority: '',
  258. productionClass: '',
  259. model: '',
  260. maker: '',
  261. tradeTerms:'',
  262. isExport:'',
  263. packagebRequirement:'',
  264. recipient:'',
  265. recipientTel:'',
  266. recipientAddress:'',
  267. paymentTerms:'',
  268. delivery:'',
  269. warrantyPeriod:'',
  270. warrantyTerms:'',
  271. exchangeRate:'',
  272. purchaseDepartment:"",
  273. purchaseman:'',
  274. currency:'',
  275. notes:''
  276. });
  277. //表单验证
  278. const validatorRules = reactive({
  279. });
  280. const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: false});
  281. const dbData = {};
  282. const formItemLayout = {
  283. labelCol: {xs: {span: 24}, sm: {span: 5}},
  284. wrapperCol: {xs: {span: 24}, sm: {span: 16}},
  285. labelCol1: {xs: {span: 24}, sm: {span: 7}},
  286. wrapperCol1: {xs: {span: 24}, sm: {span: 15}},
  287. };
  288. // 表单禁用
  289. const disabled = computed(()=>{
  290. if(props.formBpm === true){
  291. if(props.formData.disabled === false){
  292. return false;
  293. }else{
  294. return true;
  295. }
  296. }
  297. return props.formDisabled;
  298. });
  299. function add() {
  300. resetFields();
  301. PurOrderFormShipFormShipTable.dataSource = [];
  302. purOrderFormShipFormProductTable.dataSource = [];
  303. activeKey.value = 'PurOrderFormShipFormShip'
  304. formData.purchaseman=userStore.getUserInfo.username;
  305. formData.purchaseDepartment = userStore.getUserInfo.orgCode
  306. }
  307. async function copy(data,id){
  308. //主表数据
  309. await queryMainData(id);
  310. formData.id = ''
  311. formData.billCode = ''
  312. //子表数据
  313. const PurOrderFormShipFormShipDataList = await queryPurOrderFormShipFormShippTable(id);
  314. PurOrderFormShipFormShipTable.dataSource = [...PurOrderFormShipFormShipDataList];
  315. purOrderFormShipFormProductTable.dataSource = [...data];
  316. isSelect()
  317. }
  318. // 判断有没有参照的子表
  319. function isSelect(){
  320. var arrQuo = [],
  321. arrCon=[]
  322. purOrderFormShipFormProductTable.dataSource.map(item=>{
  323. var sign = ''
  324. sign = item.sourceId?(item.sourceId).substring(0, 3):''
  325. if(item.sourceId&&sign=='Quo'){
  326. arrQuo.push(item.sourceId)
  327. }else if(item.sourceId&&sign=='Con'){
  328. arrCon.push(item.sourceId)
  329. }
  330. })
  331. if(arrQuo.length==0&&arrCon.length==0){
  332. formData.sourceCode2 = ''
  333. formData.sourceCode = ''
  334. notAllowEdit.value=false
  335. }else if(arrQuo.length==0){
  336. formData.sourceCode = ''
  337. notAllowEdit.value=true
  338. }else if(arrCon.length==0){
  339. formData.sourceCode2 = ''
  340. notAllowEdit.value=true
  341. }
  342. }
  343. async function edit(row) {
  344. //主表数据
  345. await queryMainData(row.id);
  346. //子表数据
  347. const PurOrderFormShipFormShipDataList = await queryPurOrderFormShipFormShippTable(row['id']);
  348. PurOrderFormShipFormShipTable.dataSource = [...PurOrderFormShipFormShipDataList];
  349. const purOrderFormShipFormProductDataList = await queryPurOrderFormProductListByMainId(row['id']);
  350. purOrderFormShipFormProductTable.dataSource = [...purOrderFormShipFormProductDataList];
  351. notAllowEdit.value=true
  352. }
  353. async function queryMainData(id) {
  354. const row = await queryDataById(id);
  355. resetFields();
  356. const tmpData = {};
  357. Object.keys(formData).forEach((key) => {
  358. if(row.hasOwnProperty(key)){
  359. tmpData[key] = row[key]
  360. }
  361. })
  362. //赋值
  363. Object.assign(formData,tmpData);
  364. }
  365. //查看版本详情
  366. async function VersionDetail(record){
  367. //主表数据
  368. await queryVersonHistoryData(record.id);
  369. //子表数据
  370. const SaleOrderFormShipFormShipDataList = await queryPurVersonFormShipListByMainId(record.id);
  371. PurOrderFormShipFormShipTable.dataSource = [...SaleOrderFormShipFormShipDataList];
  372. const purOrderFormShipFormProductDataList = await queryPurVersonProductListByMainId(record.id);
  373. purOrderFormShipFormProductTable.dataSource = [...purOrderFormShipFormProductDataList];
  374. }
  375. async function queryVersonHistoryData(id){
  376. const row = await queryVersonHistoryById(id);
  377. resetFields();
  378. const tmpData = {};
  379. Object.keys(formData).forEach((key) => {
  380. if(row.hasOwnProperty(key)){
  381. tmpData[key] = row[key]
  382. }
  383. })
  384. //赋值
  385. Object.assign(formData,tmpData);
  386. }
  387. const {getSubFormAndTableData, transformData} = useValidateAntFormAndTable(activeKey, {
  388. 'purOrderShip': PurOrderFormShipFormShipTableRef,
  389. 'purOrderProduct': purOrderFormShipFormProductTableRef,
  390. });
  391. async function getFormData() {
  392. try {
  393. // 触发表单验证
  394. await validate();
  395. } catch ({ errorFields }) {
  396. if (errorFields) {
  397. const firstField = errorFields[0];
  398. if (firstField) {
  399. formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
  400. }
  401. }
  402. return Promise.reject(errorFields);
  403. }
  404. return transformData(toRaw(formData))
  405. }
  406. async function submitForm() {
  407. if(formData.sourceCode==''&&formData.sourceCode2==''){
  408. message.warning('请选择销售订单或报价单')
  409. }else{
  410. const mainData = await getFormData();
  411. const subData = await getSubFormAndTableData();
  412. const values = Object.assign({}, dbData, mainData, subData);
  413. console.log('表单提交数据', values)
  414. const isUpdate = values.id ? true : false
  415. const isRevise = values.submit=='1' ? true : false
  416. await saveOrUpdate(values, isUpdate,isRevise);
  417. //关闭弹窗
  418. emit('success');
  419. }
  420. }
  421. function setFieldsValue(values) {
  422. if(values){
  423. Object.keys(values).map(k=>{
  424. formData[k] = values[k];
  425. });
  426. }
  427. }
  428. function selectProductList(){
  429. SelectPrpductModalRef.value.getTable()
  430. }
  431. function onSearchProject(){
  432. SelectProjectModalRef.value.getTable()
  433. }
  434. function addProduct(data){
  435. data.map(item=>{
  436. item.productClass = item.classId_dictText
  437. item.productCode = item.code
  438. item.productId = item.id
  439. })
  440. var arrProduct = data.concat(purOrderFormShipFormProductTable.dataSource)
  441. purOrderFormShipFormProductTable.dataSource=arrProduct
  442. }
  443. function getShipList(id,status){
  444. let params = {id:id}
  445. let url = status=='quotation'?'/purCode/purPurchaseQuotation/queryPurPurchaseQuotationShipByMainId':'/saleCode/saleOrder/querySaleOrderShipByMainId'
  446. defHttp.get({url:url,params}, { isTransformResponse: false }).then(res=>{
  447. if(res){
  448. PurOrderFormShipFormShipTable.dataSource = res.result
  449. }
  450. })
  451. }
  452. function addFromQuotation(data){
  453. data.map(item=>{
  454. item.model = item.childModel
  455. item.sourceId = 'Quo'+item.childId
  456. item.sourceCode =data[0].billCode
  457. })
  458. var arrProduct = data.concat(purOrderFormShipFormProductTable.dataSource)
  459. purOrderFormShipFormProductTable.dataSource=arrProduct
  460. notAllowEdit.value=true
  461. formData.sourceCode =data[0].billCode
  462. if(formData.sourceCode2==''){
  463. formData.project = data[0].quotationProject
  464. formData.projectName = data[0].projectName
  465. formData.supplier= data[0].quotationSuppiler
  466. formData.supplierName= data[0].suppilerName
  467. formData.priority =data[0].priority
  468. formData.productionClass =data[0].productionClass
  469. formData.model =data[0].headModel
  470. formData.maker =data[0].maker
  471. getShipList(data[0].headId,'quotation')
  472. }
  473. }
  474. function addFormSaleOrder(data){
  475. data.map(item=>{
  476. item.model = item.childModel
  477. item.sourceId = 'Con'+item.childId
  478. item.sourceCode =data[0].billCode
  479. })
  480. var arrProduct = data.concat(purOrderFormShipFormProductTable.dataSource)
  481. purOrderFormShipFormProductTable.dataSource=arrProduct
  482. notAllowEdit.value=true
  483. formData.sourceCode2 =data[0].billCode
  484. if(formData.sourceCode==''){
  485. formData.project = data[0].project
  486. formData.projectName = data[0].projectName
  487. formData.priority =data[0].priority
  488. formData.productionClass =data[0].productionClass
  489. formData.model =data[0].headModel
  490. formData.maker =data[0].maker
  491. getShipList(data[0].headId,'contract')
  492. }
  493. }
  494. function addProject(data){
  495. if(data.lenght==0){
  496. formData.projectName = ''
  497. formData.projectName = ''
  498. }else{
  499. formData.project = data[0].id
  500. formData.projectName = data[0].name
  501. }
  502. }
  503. //查看配件信息
  504. function viewAccessory(prop){
  505. BaseShipArchiveAccessoriesModalRef.value.getTable(prop.row)
  506. }
  507. //产品明细-删除行
  508. function handleDelete(prop) {
  509. var newArray = [...purOrderFormShipFormProductTable.dataSource]
  510. newArray.splice(prop.rowIndex, 1)
  511. purOrderFormShipFormProductTable.dataSource = newArray
  512. if( purOrderFormShipFormProductTable.dataSource.length!==0){
  513. var arrQuo = [],
  514. arrCon=[]
  515. purOrderFormShipFormProductTable.dataSource.map(item=>{
  516. var sign = ''
  517. sign = item.sourceId?(item.sourceId).substring(0, 3):''
  518. if(item.sourceId&&sign=='Quo'){
  519. arrQuo.push(item.sourceId)
  520. }else if(item.sourceId&&sign=='Con'){
  521. arrCon.push(item.sourceId)
  522. }
  523. })
  524. if(arrQuo.length==0&&arrCon.length==0){
  525. formData.sourceCode2 = ''
  526. formData.sourceCode = ''
  527. notAllowEdit.value=false
  528. }else if(arrQuo.length==0){
  529. formData.sourceCode = ''
  530. }else if(arrCon.length==0){
  531. formData.sourceCode2 = ''
  532. }
  533. }else{
  534. notAllowEdit.value=false
  535. formData.sourceCode2 = ''
  536. formData.sourceCode = ''
  537. }
  538. }
  539. //选择供应商报价单
  540. function SelectSupplierQuotationList (){
  541. SelectSupplierQuotationModalRef.value.getTable(formData)
  542. }
  543. // 选择销售订单
  544. function selectSaleOrderList(){
  545. SelectSaleOrderModalRef.value.getTable(formData)
  546. }
  547. /**
  548. * 值改变事件触发-树控件回调
  549. * @param key
  550. * @param value
  551. */
  552. function handleFormChange(key, value) {
  553. formData[key] = value;
  554. }
  555. return {
  556. PurOrderFormShipFormShipTableRef,
  557. PurOrderFormShipFormShipTable,
  558. purOrderFormShipFormProductTableRef,
  559. purOrderFormShipFormProductTable,
  560. SelectSupplierQuotationModalRef,
  561. SelectSaleOrderModalRef,
  562. validatorRules,
  563. validateInfos,
  564. activeKey,
  565. loading,
  566. formData,
  567. setFieldsValue,
  568. handleFormChange,
  569. formItemLayout,
  570. disabled,
  571. getFormData,
  572. submitForm,
  573. add,
  574. edit,
  575. copy,
  576. formRef,
  577. selectProductList,
  578. SelectPrpductModalRef,
  579. addProduct,
  580. onSearchProject,
  581. SelectProjectModalRef,
  582. addProject,
  583. handleDelete,
  584. BaseShipArchiveAccessoriesModalRef,
  585. viewAccessory,
  586. VersionDetail,
  587. SelectSupplierQuotationList,
  588. addFromQuotation,
  589. notAllowEdit,
  590. selectSaleOrderList,
  591. addFormSaleOrder
  592. }
  593. }
  594. });
  595. </script>
  596. <style lang="less" scoped>
  597. /** 时间和数字输入框样式 */
  598. :deep(.ant-input-number) {
  599. width: 100%;
  600. }
  601. :deep(.ant-calendar-picker) {
  602. width: 100%;
  603. }
  604. /deep/.vxe-table--body-wrapper{
  605. height: 100% !important;
  606. }
  607. /deep/.ant-modal-body{
  608. padding: 24px !important;
  609. }
  610. /deep/.ant-form-item{
  611. margin-bottom: 8px !important;
  612. }
  613. </style>