quotationFormForm.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. <template>
  2. <a-spin :spinning="loading">
  3. <JFormContainer :disabled="disabled">
  4. <template #detail>
  5. <a-form v-bind="formItemLayout" name="quotationFormForm" ref="formRef">
  6. <a-row>
  7. <a-col :span="12">
  8. <a-form-item label="报价单号(bill code)" v-bind="validateInfos.billCode" id="quotationFormForm-billCode" name="billCode" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  9. <a-input v-model:value="formData.billCode" placeholder="自动生成" 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" id="quotationFormForm-billDate" name="billDate">
  14. <a-date-picker placeholder="请选择单据日期(bill date)" v-model:value="formData.billDate" value-format="YYYY-MM-DD" disabled style="width: 100%" allow-clear />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="12">
  18. <a-form-item label="报价项目(quotation project)" v-bind="validateInfos.quotationProjectName" id="quotationFormForm-quotationProjectName" name="quotationProjectName">
  19. <a-input-search v-model:value="formData.quotationProjectName" placeholder="请输入报价项目(inquiry project)" allow-clear enter-button="Search" :disabled="notAllowEdit" @search="onSearchProject"></a-input-search>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :span="12">
  23. <a-form-item label="报价客户(quotation customer)" v-bind="validateInfos.quotationCustomer" id="quotationFormForm-quotationCustomer" name="quotationCustomer" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  24. <JSelectInput v-model:value="formData.quotationCustomer" placeholder="请选择" :options="customerOption" disabled></JSelectInput>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="12">
  28. <a-form-item label="报价有效期(quotation period)" v-bind="validateInfos.quotationPeriod" id="quotationFormForm-quotationPeriod" name="quotationPeriod">
  29. <a-range-picker v-model:value="quotationPeriod" :format="['YYYY-MM-DD','YYYY-MM-DD']" @change="onChangequotationPeriod" style="width: 100%" />
  30. </a-form-item>
  31. </a-col>
  32. <a-col :span="12">
  33. <a-form-item label="优先级(priority)" v-bind="validateInfos.priority" id="quotationFormForm-priority" name="priority">
  34. <JDictSelectTag v-model:value="formData.priority" placeholder="请选择" dictCode="priority"/>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :span="12">
  38. <a-form-item label="产品分类(production class)" v-bind="validateInfos.productionClass" id="quotationFormForm-productionClass" name="productionClass" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  39. <JSelectInput v-model:value="formData.productionClass" placeholder="请选择" :options="classOption"></JSelectInput>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :span="12">
  43. <a-form-item label="机型(model)" v-bind="validateInfos.model" id="quotationFormForm-model" name="model">
  44. <JSelectMultiple v-model:value="formData.model" placeholder="请选择" dictCode="model_typer"/>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="12">
  48. <a-form-item label="厂家(maker)" v-bind="validateInfos.maker" id="quotationFormForm-maker" name="maker" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  49. <JDictSelectTag v-model:value="formData.maker" placeholder="请选择" dictCode="factory"/>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :span="12">
  53. <a-form-item label="币种(currency)" v-bind="validateInfos.currency" id="quotationFormForm-currency" name="currency" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  54. <JDictSelectTag v-model:value="formData.currency" placeholder="请选择" dictCode="currency" />
  55. </a-form-item>
  56. </a-col>
  57. <a-col :span="12">
  58. <a-form-item label="汇率(exchangeRate)" v-bind="validateInfos.exchangeRate" id="quotationFormForm-exchangeRate" name="exchangeRate" >
  59. <a-input-number v-model:value="formData.exchangeRate" placeholder="请输入" allow-clear AutoComplete="off" @change="changeDiscountOrExchangeRate" suffix="%"></a-input-number>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :span="12">
  63. <a-form-item label="贸易方式(delivery terms)" v-bind="validateInfos.deliveryTerms" id="quotationFormForm-deliveryTerms" name="deliveryTerms" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  64. <JDictSelectTag v-model:value="formData.deliveryTerms" placeholder="请选择" dictCode="delivery_terms"/>
  65. </a-form-item>
  66. </a-col>
  67. <a-col :span="12">
  68. <a-form-item label="交期(delivery time)" v-bind="validateInfos.deliveryDayHead" id="quotationFormForm-deliveryDayHead" name="deliveryDayHead">
  69. <a-input-number placeholder="" v-model:value="formData.deliveryDayHead" @change="changeDelivertTime" style="width: 100%" allow-clear />
  70. </a-form-item>
  71. </a-col>
  72. <a-col :span="12">
  73. <a-form-item label="付款条件(payment terms)" v-bind="validateInfos.paymentTerms" id="quotationFormForm-paymentTerms" name="paymentTerms" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  74. <JDictSelectTag v-model:value="formData.paymentTerms" placeholder="请选择" dictCode="payment_terms"/>
  75. </a-form-item>
  76. </a-col>
  77. <a-col :span="12">
  78. <a-form-item label="交货地点(place of delivery)" v-bind="validateInfos.placeDelivery" id="quotationFormForm-placeDelivery" name="placeDelivery">
  79. <a-input v-model:value="formData.placeDelivery" placeholder="请输入交货地点(place of delivery)" allow-clear AutoComplete="off"></a-input>
  80. </a-form-item>
  81. </a-col>
  82. <a-col :span="12">
  83. <a-form-item label="客户折扣(custumer discount)" v-bind="validateInfos.custumerDiscount" id="quotationFormForm-custumerDiscount" name="custumerDiscount" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  84. <a-input v-model:value="formData.custumerDiscount" placeholder="请输入客户折扣(custumer discount)" allow-clear AutoComplete="off" @change="changeDiscountOrExchangeRate" suffix="%"></a-input>
  85. </a-form-item>
  86. </a-col>
  87. <a-col :span="12">
  88. <a-form-item label="销售部门(sale department)" v-bind="validateInfos.saleDepartment" id="SaleInquiryFormForm-saleDepartment" name="saleDepartment">
  89. <a-input v-model:value="formData.saleDepartmentName" placeholder="" allow-clear disabled></a-input>
  90. </a-form-item>
  91. </a-col>
  92. <a-col :span="12">
  93. <a-form-item label="包装方式(packaging method)" v-bind="validateInfos.packagingMethod" id="quotationFormForm-packagingMethod" name="packagingMethod" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  94. <a-input v-model:value="formData.packagingMethod" placeholder="请输入包装方式(packaging method)" allow-clear AutoComplete="off"></a-input>
  95. </a-form-item>
  96. </a-col>
  97. <a-col :span="12">
  98. <a-form-item label="业务员(salesman)" v-bind="validateInfos.salesman" id="quotationFormForm-salesman" name="salesman">
  99. <a-input v-model:value="formData.salesmanName" placeholder="" allow-clear disabled></a-input>
  100. </a-form-item>
  101. </a-col>
  102. <a-col :span="12">
  103. <a-form-item label="报价备注(quotation notes)" v-bind="validateInfos.quotationNotes" id="quotationFormForm-quotationNotes" name="quotationNotes" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  104. <a-input v-model:value="formData.quotationNotes" placeholder="请输入报价备注(quotation notes)" allow-clear AutoComplete="off"></a-input>
  105. </a-form-item>
  106. </a-col>
  107. <a-col :span="12">
  108. <a-form-item label="附件(attachs)" v-bind="validateInfos.attachs" id="quotationFormForm-attachs" name="attachs">
  109. <JUpload v-model:value="formData.attachs"></JUpload>
  110. </a-form-item>
  111. </a-col>
  112. <a-col :span="12">
  113. <a-form-item label="供应商技术资料(supplier quotation attachs)" v-bind="validateInfos.supplierAttachs" id="quotationFormForm-supplierAttachs" name="supplierAttachs" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
  114. <a :href="baseUrl+formData.supplierAttachs" v-if="formData.supplierAttachs">{{formData.supplierAttachs}}</a>
  115. <a-input v-model:value="formData.supplierAttachs" disabled v-if="!formData.supplierAttachs"></a-input>
  116. </a-form-item>
  117. </a-col>
  118. </a-row>
  119. </a-form>
  120. </template>
  121. </JFormContainer>
  122. <!-- 子表单区域 -->
  123. <a-tabs v-model:activeKey="activeKey" animated style=" padding: 24px;padding-top: 0px;">
  124. <a-tab-pane tab="销售报价单 - 产品明细(product details)" key="saleQuotationFormProduct" :forceRender="true">
  125. <a-button type="primary" @click="selectProducts" style="margin-right: 1%;margin-bottom: 1%;"> 选择产品(select product)</a-button>
  126. <a-button type="primary" @click="chooseSupplier"> 选择供应商报价(selete supplier quotation)</a-button>
  127. <j-vxe-table
  128. :keep-source="true"
  129. resizable
  130. ref="saleQuotationFormProductTableRef"
  131. :loading="saleQuotationFormProductTable.loading"
  132. :columns="saleQuotationFormProductTable.columns"
  133. :dataSource="saleQuotationFormProductTable.dataSource"
  134. :height="340"
  135. :disabled="disabled"
  136. :rowNumber="true"
  137. :rowSelection="true"
  138. asyncRemove
  139. @valueChange="changeValues"
  140. >
  141. <template #lastPrice="props">
  142. <a @click="viewHistory">{{ props.row.lastPrice }}</a>
  143. </template>
  144. <template #action="props">
  145. <a-popconfirm title="确定删除吗?" @confirm="handleDelete1(props)">
  146. <a>删除(delete)</a>
  147. </a-popconfirm>
  148. </template>
  149. </j-vxe-table>
  150. </a-tab-pane>
  151. <a-tab-pane tab="销售报价单 - 船明细(ship details)" key="saleQuotationFormShip" :forceRender="true">
  152. <a-button type="primary" @click="selectShip"> 选择船(select ship)</a-button>
  153. <j-vxe-table
  154. :keep-source="true"
  155. resizable
  156. ref="saleQuotationFormShipTableRef"
  157. :loading="saleQuotationFormShipTable.loading"
  158. :columns="saleQuotationFormShipTable.columns"
  159. :dataSource="saleQuotationFormShipTable.dataSource"
  160. :height="340"
  161. :disabled="disabled"
  162. :rowNumber="true"
  163. :rowSelection="true"
  164. >
  165. <template #action="props" >
  166. <a @click="viewAccessory(props)" >查看配件信息(view accessory information)</a>
  167. <a-divider type="vertical"/>
  168. <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)">
  169. <a>删除(delete)</a>
  170. </a-popconfirm>
  171. </template>
  172. </j-vxe-table>
  173. </a-tab-pane>
  174. </a-tabs>
  175. <SelectShipSModal ref="SelectShipSModalRef" @select="addShip"></SelectShipSModal>
  176. <BaseShipArchiveAccessoriesModal ref="BaseShipArchiveAccessoriesListRef"></BaseShipArchiveAccessoriesModal>
  177. <SelectPrpductModal ref="SelectPrpductModalRef" @selectProduct="addProduct"></SelectPrpductModal>
  178. <SelectProjectModal ref="SelectProjectModalRef" @selectProject="addProject"></SelectProjectModal>
  179. <ViewHistoryQuotationModal ref="ViewHistoryQuotationModalRef" ></ViewHistoryQuotationModal>
  180. <SelectSupplierQuotation ref="SelectSupplierQuotationRef" @selectSupplierQuatationConfirm="addProductFromSupplier"></SelectSupplierQuotation>
  181. </a-spin>
  182. </template>
  183. <script lang="ts">
  184. import { defineComponent, ref, reactive, computed, toRaw, onMounted } from 'vue';
  185. import { defHttp } from '/@/utils/http/axios';
  186. import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
  187. import { querysaleQuotationFormShipListByMainId,querysaleVersonFormShipListByMainId,querySaleQuotationFormProductListByMainId, querySaleVersonProductListByMainId,queryDataById, saveOrUpdate,HistoryQuotation,queryVersonHistoryById } from '../quotationForm.api';
  188. import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  189. import {saleQuotationFormShipColumns, saleQuotationFormProductColumns} from '../quotationForm.data';
  190. import SelectShipSModal from '../../../publicComponents/SelectShipSModal.vue';
  191. import BaseShipArchiveAccessoriesModal from '../../../publicComponents/BaseShipArchiveAccessoriesModal.vue';
  192. import SelectPrpductModal from '../../../publicComponents/SelectPrpductModal.vue';
  193. import SelectProjectModal from '../../../publicComponents/SelectProjectModal.vue';
  194. import SelectSupplierQuotation from '../../../publicComponents/SelectSupplierQuotation.vue';
  195. import ViewHistoryQuotationModal from './ViewHistoryQuotationModal.vue';
  196. import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  197. import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  198. import { JDictSelectTag,JSelectMultiple} from '/@/components/Form';
  199. import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  200. import { Form,message } from 'ant-design-vue';
  201. import { useUserStore } from '/@/store/modules/user';
  202. import moment from 'moment';
  203. import { useGlobSetting } from '/@/hooks/setting';
  204. const { domainUrl } = useGlobSetting();
  205. const userStore = useUserStore();
  206. const useForm = Form.useForm;
  207. export default defineComponent({
  208. name: "quotationFormForm",
  209. components:{
  210. JVxeTable,
  211. JFormContainer,
  212. SelectShipSModal,
  213. BaseShipArchiveAccessoriesModal,
  214. SelectPrpductModal,
  215. JUpload,
  216. SelectProjectModal,
  217. SelectSupplierQuotation,
  218. ViewHistoryQuotationModal,
  219. JDictSelectTag,
  220. JSelectInput,
  221. JSelectMultiple
  222. },
  223. props:{
  224. formDisabled:{
  225. type: Boolean,
  226. default: false
  227. },
  228. formData: { type: Object, default: ()=>{} },
  229. formBpm: { type: Boolean, default: true }
  230. },
  231. emits:['success'],
  232. setup(props, {emit}) {
  233. const baseUrl = domainUrl + '/sys/common/static/';
  234. const loading = ref(false);
  235. const formRef = ref();
  236. var SelectPrpductModalRef = ref()
  237. var SelectProjectModalRef = ref()
  238. var ViewHistoryQuotationModalRef = ref()
  239. var SelectSupplierQuotationRef = ref()
  240. var quotationPeriod = ref([])
  241. const saleQuotationFormShipTableRef = ref();
  242. const saleQuotationFormShipTable = reactive<Record<string, any>>({
  243. loading: false,
  244. columns:saleQuotationFormShipColumns,
  245. dataSource: []
  246. });
  247. const saleQuotationFormProductTableRef = ref();
  248. const saleQuotationFormProductTable = reactive<Record<string, any>>({
  249. loading: false,
  250. columns: saleQuotationFormProductColumns,
  251. dataSource: []
  252. });
  253. var SelectShipSModalRef = ref();
  254. var BaseShipArchiveAccessoriesListRef = ref();
  255. const activeKey = ref('saleQuotationFormProduct');
  256. var notAllowEdit = ref(false);
  257. var classOption = ref([]);
  258. var customerOption =ref([]);
  259. const formData = reactive<Record<string, any>>({
  260. id: '',
  261. status: undefined,
  262. delFlag: undefined,
  263. otherStatus: '',
  264. billDate: moment(new Date()).format('YYYY-MM-DD'),
  265. billCode: '',
  266. quotationProject: '',
  267. quotationProjectName: '',
  268. quotationCustomer: '',
  269. quotationCustomerName: '',
  270. quotationPeriodBegin: '',
  271. quotationPeriodEnd: '',
  272. busynessType: '',
  273. priority: '',
  274. productionClass: '',
  275. model: '',
  276. maker: '',
  277. currency:"",
  278. deliveryTerms: '',
  279. deliveryDayHead: '',
  280. paymentTerms: '',
  281. placeDelivery: '',
  282. custumerDiscount: '',
  283. saleDepartment:'',
  284. saleDepartmentName: '',
  285. packagingMethod:'',
  286. salesman: '',
  287. salesmanName: '',
  288. quotationNotes:"",
  289. attachs: '',
  290. supplierAttachs: '',
  291. sourceCode:'',
  292. exchangeRate:''
  293. });
  294. //表单验证
  295. const validatorRules = reactive({
  296. });
  297. const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: false});
  298. const dbData = {};
  299. const formItemLayout = {
  300. labelCol: {xs: {span: 24}, sm: {span: 8}},
  301. wrapperCol: {xs: {span: 24}, sm: {span: 13}},
  302. labelCol1: {xs: {span: 24}, sm: {span: 8}},
  303. wrapperCol1: {xs: {span: 24}, sm: {span: 13}},
  304. };
  305. // 表单禁用
  306. const disabled = computed(()=>{
  307. if(props.formBpm === true){
  308. if(props.formData.disabled === false){
  309. return false;
  310. }else{
  311. return true;
  312. }
  313. }
  314. return props.formDisabled;
  315. });
  316. //新增方法
  317. function add() {
  318. resetFields();
  319. saleQuotationFormShipTable.dataSource = [];
  320. saleQuotationFormProductTable.dataSource = [];
  321. activeKey.value = 'saleQuotationFormProduct'
  322. getOptiom()
  323. getCustomerOptions()
  324. quotationPeriod.value = []
  325. formData.salesman=userStore.getUserInfo.username;
  326. formData.salesmanName=userStore.getUserInfo.realname;
  327. formData.saleDepartment = userStore.getUserInfo.orgCode
  328. formData.saleDepartmentName = userStore.getUserInfo.orgName
  329. notAllowEdit.value = false
  330. }
  331. //编辑方法
  332. async function edit(row) {
  333. //主表数据
  334. await queryMainData(row.id);
  335. //子表数据
  336. const saleQuotationFormShipDataList = await querysaleQuotationFormShipListByMainId(row['id']);
  337. saleQuotationFormShipTable.dataSource = [...saleQuotationFormShipDataList];
  338. const saleQuotationFormProductDataList = await querySaleQuotationFormProductListByMainId(row['id']);
  339. saleQuotationFormProductTable.dataSource = [...saleQuotationFormProductDataList];
  340. getOptiom()
  341. getCustomerOptions()
  342. quotationPeriod.value[0]=formData.quotationPeriodBegin?moment(formData.quotationPeriodBegin):''
  343. quotationPeriod.value[1]=formData.quotationPeriodEnd?moment(formData.quotationPeriodEnd):''
  344. notAllowEdit.value=true
  345. }
  346. //获取主表
  347. async function queryMainData(id) {
  348. const row = await queryDataById(id);
  349. resetFields();
  350. const tmpData = {};
  351. Object.keys(formData).forEach((key) => {
  352. if(row.hasOwnProperty(key)){
  353. tmpData[key] = row[key]
  354. }
  355. })
  356. //赋值
  357. Object.assign(formData,tmpData);
  358. }
  359. const {getSubFormAndTableData, transformData} = useValidateAntFormAndTable(activeKey, {
  360. 'saleQuotationShip': saleQuotationFormShipTableRef,
  361. 'saleQuotationProduct': saleQuotationFormProductTableRef,
  362. });
  363. //获取表单信息
  364. async function getFormData() {
  365. try {
  366. // 触发表单验证
  367. await validate();
  368. } catch ({ errorFields }) {
  369. if (errorFields) {
  370. const firstField = errorFields[0];
  371. if (firstField) {
  372. formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
  373. }
  374. }
  375. return Promise.reject(errorFields);
  376. }
  377. return transformData(toRaw(formData))
  378. }
  379. //保存
  380. async function submitForm() {
  381. if(formData.sourceCode==''){
  382. message.warning('请选择供应商报价单')
  383. }else{
  384. const mainData = await getFormData();
  385. const subData = await getSubFormAndTableData();
  386. const values = Object.assign({}, dbData, mainData, subData);
  387. console.log('表单提交数据', values)
  388. const isUpdate = values.id ? true : false
  389. const isRevise = values.status=='1' ? true : false
  390. await saveOrUpdate(values, isUpdate,isRevise);
  391. //关闭弹窗
  392. emit('success');
  393. }
  394. }
  395. function setFieldsValue(values) {
  396. if(values){
  397. Object.keys(values).map(k=>{
  398. formData[k] = values[k];
  399. });
  400. }
  401. }
  402. /**
  403. * 值改变事件触发-树控件回调
  404. * @param key
  405. * @param value
  406. */
  407. function handleFormChange(key, value) {
  408. formData[key] = value;
  409. }
  410. //传明细-删除行
  411. async function handleDelete(prop) {
  412. var newArray = [...saleQuotationFormShipTable.dataSource]
  413. newArray.splice(prop.rowIndex, 1)
  414. saleQuotationFormShipTable.dataSource = newArray
  415. }
  416. //产品明细-删除行
  417. async function handleDelete1(prop) {
  418. var newArray = [...saleQuotationFormProductTable.dataSource]
  419. newArray.splice(prop.rowIndex, 1)
  420. saleQuotationFormProductTable.dataSource = newArray
  421. if( saleQuotationFormProductTable.dataSource.length!==0){
  422. var arr = []
  423. saleQuotationFormProductTable.dataSource.map(item=>{
  424. if(item.sourceId){
  425. arr.push(item.sourceId)
  426. }
  427. })
  428. if(arr.length==0){
  429. formData.sourceCode=''
  430. notAllowEdit.value=false
  431. }
  432. }else{
  433. formData.sourceCode=''
  434. notAllowEdit.value=false
  435. }
  436. }
  437. //查询船
  438. function selectShip(){
  439. SelectShipSModalRef.value.getTable()
  440. }
  441. //增行-船明细
  442. function addShip(data){
  443. var arr = data.concat(saleQuotationFormShipTable.dataSource)
  444. arr.map(item=>item.shipowner = item.relateCustomer)
  445. saleQuotationFormShipTable.dataSource=arr
  446. }
  447. //增行-产品明细
  448. async function addProduct(data){
  449. for (const item of data){
  450. item.productClass = item.classId_dictText
  451. item.productCode = item.code
  452. // item.unit = item.measurementUnit
  453. item.deliveryDayChild = formData.deliveryDayHead
  454. item.productId = item.id
  455. var obj = await getRowRate(item)
  456. item.taxRate = obj.rateNumber
  457. item.grossMargin = obj.grossMargin
  458. item.discount= formData.custumerDiscount!==''?formData.custumerDiscount:''
  459. }
  460. var arrProduct = data.concat(saleQuotationFormProductTable.dataSource)
  461. saleQuotationFormProductTable.dataSource=arrProduct
  462. }
  463. //选择项目
  464. function addProject(data) {
  465. if(data.length==0){
  466. formData.quotationProject =
  467. formData.quotationProjectName = ''
  468. }else{
  469. formData.quotationProject = data[0].id
  470. formData.quotationProjectName = data[0].code
  471. formData.quotationCustomer =data[0].customerId
  472. formData.quotationCustomerName =data[0].customerId_dictText
  473. formData.custumerDiscount==data[0].discount
  474. customerOption.value.map(item=>{
  475. if(item.value==data[0].customerId){
  476. formData.priority =item.priority
  477. formData.custumerDiscount=item.discount
  478. formData.paymentTerms=item.paymentTerms
  479. }
  480. })
  481. if(saleQuotationFormProductTable.dataSource.length>0){
  482. var newArr = [...saleQuotationFormProductTable.dataSource]
  483. newArr.map(item=>{
  484. item.discount = formData.custumerDiscount
  485. })
  486. saleQuotationFormProductTable.dataSource = newArr
  487. }
  488. }
  489. }
  490. //获取客户列表
  491. function getCustomerOptions(){
  492. let params = {pageSize:'-1',status:1}
  493. defHttp.get({url:'/cuspCode/cuspCustomerProfile/list',params}, { isTransformResponse: false }).then(res=>{
  494. if(res){
  495. customerOption.value = []
  496. res.result.records.forEach(item=>{
  497. customerOption.value.push({
  498. label: item.name,
  499. value: item.id,
  500. priority:item.priority,
  501. intermediatorCommission:item.intermediatorCommission,
  502. commission:item.commission,
  503. discount:item.discount,
  504. paymentTerms:item.paymentTerms
  505. })
  506. })
  507. }
  508. })
  509. }
  510. //查看配件信息
  511. function viewAccessory(prop){
  512. BaseShipArchiveAccessoriesListRef.value.getTable(prop.row)
  513. }
  514. //选择产品
  515. function selectProducts(){
  516. SelectPrpductModalRef.value.getTable()
  517. }
  518. //选择供应商报价单
  519. function chooseSupplier(){
  520. SelectSupplierQuotationRef.value.getTable(formData)
  521. }
  522. //选择项目
  523. function onSearchProject(){
  524. SelectProjectModalRef.value.getTable()
  525. }
  526. //获取产品分类下拉框
  527. function getOptiom(){
  528. defHttp
  529. .get({ url: 'baseCode/baseProductClass/list'}, { isTransformResponse: false })
  530. .then((res) => {
  531. if (res.success) {
  532. classOption.value = []
  533. res.result.records.forEach(element => {
  534. var obj = {
  535. label: element.name?element.name:'无名称请维护',
  536. value: element.id?element.id:'',
  537. taxRate: element.taxRate?element.taxRate:0,
  538. grossMargin: element.grossMargin?element.grossMargin:0
  539. };
  540. classOption.value.push( obj)
  541. });
  542. }
  543. })
  544. .finally(() => {
  545. // loading.value = false;
  546. });
  547. }
  548. //修改报价有效期
  549. function onChangequotationPeriod(data){
  550. quotationPeriod.value = data
  551. formData.quotationPeriodBegin = data[0].format('YYYY-MM-DD')
  552. formData.quotationPeriodEnd = data[1].format('YYYY-MM-DD')
  553. }
  554. //修改主表交期
  555. function changeDelivertTime(){
  556. if(saleQuotationFormProductTable.dataSource.length>0){
  557. const xTable = saleQuotationFormProductTableRef.value!.getXTable();
  558. var newArr = [...xTable.data]
  559. newArr.map(item=>{
  560. item.deliveryDayChild = formData.deliveryDayHead
  561. })
  562. saleQuotationFormProductTable.dataSource = newArr
  563. }
  564. }
  565. //查看上次报价
  566. function viewHistory(){
  567. ViewHistoryQuotationModalRef.value.getTable()
  568. }
  569. //查看版本详情
  570. async function VersionDetail(record){
  571. //主表数据
  572. await queryVersonHistoryData(record.id);
  573. //子表数据
  574. const saleQuotationFormShipDataList = await querysaleVersonFormShipListByMainId(record.id);
  575. saleQuotationFormShipTable.dataSource = [...saleQuotationFormShipDataList];
  576. const saleQuotationFormProductDataList = await querySaleVersonProductListByMainId(record.id);
  577. saleQuotationFormProductTable.dataSource = [...saleQuotationFormProductDataList];
  578. getOptiom()
  579. getCustomerOptions()
  580. quotationPeriod.value[0]=formData.quotationPeriodBegin?moment(formData.quotationPeriodBegin):''
  581. quotationPeriod.value[1]=formData.quotationPeriodEnd?moment(formData.quotationPeriodEnd):''
  582. }
  583. async function queryVersonHistoryData(id){
  584. const row = await queryVersonHistoryById(id);
  585. resetFields();
  586. const tmpData = {};
  587. Object.keys(formData).forEach((key) => {
  588. if(row.hasOwnProperty(key)){
  589. tmpData[key] = row[key]
  590. }
  591. })
  592. //赋值
  593. Object.assign(formData,tmpData);
  594. }
  595. //新增行-产品明细-选择供应商报价单
  596. async function addProductFromSupplier(data){
  597. //查询客户名称
  598. var obj = await SelectProjectModalRef.value.getCustom(data[0].inquiryProject)
  599. formData.quotationCustomer =obj.length==0?'':obj[0].customerId
  600. formData.quotationCustomerName =obj.length==0?'':obj[0].customerId_dictText
  601. for (const item of data){
  602. var obj = await getRowRate(item)
  603. item.taxRate = obj.rateNumber
  604. item.grossMargin = obj.grossMargin
  605. item.productClass = item.productClass
  606. item.productCode = item.productCode
  607. item.sourceId = item.childId
  608. item.fatherModel = item.model
  609. item.model = item.childModel
  610. item.deliveryTime = formData.deliveryTime
  611. item.supplierCurrency = item.currency
  612. item.supplierId = item.selectionSupplier
  613. item.supplierName = item.selectionSupplier_dictText
  614. item.purchasePrice = item.taxPrice
  615. item.taxAmount = 0
  616. }
  617. var arrProduct = data.concat(saleQuotationFormProductTable.dataSource)
  618. arrProduct.map(item=>{
  619. customerOption.value.map(event=>{
  620. if(event.value==formData.quotationCustomer){
  621. item.intermediatorCommission = event.intermediatorCommission,
  622. item.customerCommision = event.commission
  623. formData.custumerDiscount=event.discount
  624. item.discount = event.discount
  625. formData.paymentTerms = event.paymentTerms
  626. }
  627. })
  628. })
  629. saleQuotationFormProductTable.dataSource=arrProduct
  630. notAllowEdit.value=true
  631. formData.quotationProject = data[0].inquiryProject
  632. formData.quotationProjectName = data[0].projectName
  633. formData.sourceCode = data[0].billCode
  634. formData.priority = data[0].priority
  635. formData.model = data[0].fatherModel
  636. formData.maker = data[0].maker
  637. formData.productionClass = data[0].productionClass
  638. formData.deliveryDayHead = data[0].deliveryDayChild
  639. }
  640. async function getRowRate(row){
  641. var obj= {
  642. rateNumber:0,
  643. grossMargin:0
  644. }
  645. let params = {pageSize:'-1',status:1,code:row.productCode}
  646. await defHttp.get({url:'/baseCode/baseProductArchive/list',params}, { isTransformResponse: false }).then(res=>{
  647. if(res){
  648. if(res.result.records[0].taxRate&&res.result.records[0].taxRate!==''){
  649. obj.rateNumber= res.result.records[0].taxRate
  650. }else{
  651. classOption.value.map(event=>{
  652. if(event.label==row.productClass){
  653. obj.rateNumber = event.taxRate
  654. }
  655. })
  656. }
  657. classOption.value.map(event=>{
  658. if(event.label==row.productClass){
  659. obj.grossMargin = event.grossMargin
  660. }
  661. })
  662. }
  663. })
  664. return obj
  665. }
  666. function changeValues(prop){
  667. if(prop.col.key=='purchasePrice'||prop.col.key=='taxRate'||prop.col.key=='tariff'||prop.col.key=='discount'||prop.col.key=='grossMargin'||prop.col.key=='customerCommision'||prop.col.key=='intermediatorCommission'){
  668. //汇率默认为1
  669. formData.exchangeRate = (formData.exchangeRate==''||formData.exchangeRate===null)?1:formData.exchangeRate
  670. var num= prop.row.purchasePrice/Number(formData.exchangeRate)*(1+prop.row.taxRate/100)*(1+prop.row.tariff/100)*(1-prop.row.discount/100)/(1-prop.row.grossMargin/100-prop.row.customerCommision/100-prop.row.intermediatorCommission/100)
  671. prop.row.salePrice = num.toFixed(2)
  672. if(prop.row.quantity){
  673. prop.row.taxAmount = (prop.row.salePrice*prop.row.quantity).toFixed(2)
  674. }
  675. }
  676. if(prop.col.key=='quantity'&&prop.row.salePrice&&prop.row.quantity){
  677. prop.row.taxAmount = (prop.row.salePrice*prop.row.quantity).toFixed(2)
  678. }
  679. }
  680. function changeDiscountOrExchangeRate(){
  681. if(saleQuotationFormProductTable.dataSource.length>0){
  682. const xTable = saleQuotationFormProductTableRef.value!.getXTable();
  683. var newArr = [...xTable.data]
  684. formData.exchangeRate = (formData.exchangeRate==''||formData.exchangeRate===null)?1:formData.exchangeRate
  685. newArr.map(item=>{
  686. item.discount = formData.custumerDiscount
  687. if(item.purchasePrice&&item.taxRate&&item.tariff&&item.discount&&item.grossMargin&&item.customerCommision&&item.intermediatorCommission){
  688. //汇率默认为1
  689. var num= item.purchasePrice/Number(formData.exchangeRate)*(1+item.taxRate/100)*(1+item.tariff/100)*(1-item.discount/100)/(1-item.grossMargin/100-item.customerCommision/100-item.intermediatorCommission/100)
  690. item.salePrice = num.toFixed(2)
  691. if(item.quantity){
  692. item.taxAmount = (item.salePrice*item.quantity).toFixed(2)
  693. }
  694. }
  695. })
  696. saleQuotationFormProductTable.dataSource = newArr
  697. }
  698. }
  699. return {
  700. saleQuotationFormShipTableRef,
  701. saleQuotationFormShipTable,
  702. saleQuotationFormProductTableRef,
  703. saleQuotationFormProductTable,
  704. validatorRules,
  705. validateInfos,
  706. activeKey,
  707. loading,
  708. formData,
  709. setFieldsValue,
  710. handleFormChange,
  711. formItemLayout,
  712. disabled,
  713. getFormData,
  714. submitForm,
  715. SelectShipSModalRef,
  716. add,
  717. edit,
  718. formRef,
  719. selectShip,
  720. addShip,
  721. addProduct,
  722. BaseShipArchiveAccessoriesListRef,
  723. viewAccessory,
  724. handleDelete,
  725. handleDelete1,
  726. selectProducts,
  727. SelectPrpductModalRef,
  728. SelectProjectModalRef,
  729. ViewHistoryQuotationModalRef,
  730. SelectSupplierQuotationRef,
  731. onSearchProject,
  732. addProject,
  733. getOptiom,
  734. classOption,
  735. getCustomerOptions,
  736. customerOption,
  737. quotationPeriod,
  738. onChangequotationPeriod,
  739. chooseSupplier,
  740. changeDelivertTime,
  741. viewHistory,
  742. baseUrl,
  743. VersionDetail,
  744. queryVersonHistoryData,
  745. addProductFromSupplier,
  746. notAllowEdit,
  747. changeValues,
  748. getRowRate,
  749. changeDiscountOrExchangeRate,
  750. }
  751. }
  752. });
  753. </script>
  754. <style lang="less" scoped>
  755. /** 时间和数字输入框样式 */
  756. :deep(.ant-input-number) {
  757. width: 100%;
  758. }
  759. :deep(.ant-calendar-picker) {
  760. width: 100%;
  761. }
  762. /deep/.vxe-table--body-wrapper{
  763. height: 100% !important;
  764. }
  765. /deep/.ant-modal-body{
  766. padding: 24px !important;
  767. }
  768. /deep/.ant-form-item{
  769. margin-bottom: 8px !important;
  770. }
  771. </style>