SaleInquiryFormForm.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <a-spin :spinning="loading">
  3. <JFormContainer :disabled="disabled">
  4. <template #detail>
  5. <a-form v-bind="formItemLayout" name="SaleInquiryFormForm" ref="formRef">
  6. <a-row>
  7. <a-col :span="12">
  8. <a-form-item label="询价单号(bill code)" v-bind="validateInfos.billCode" id="SaleInquiryFormForm-billCode" name="billCode">
  9. <a-input v-model:value="formData.billCode" placeholder="自动生成" disabled />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :span="12">
  13. <a-form-item label="单据日期(bill date)" v-bind="validateInfos.billDate" id="SaleInquiryFormForm-billDate" name="billDate">
  14. <a-date-picker disabled
  15. placeholder="请选择单据日期(bill date)"
  16. v-model:value="formData.billDate"
  17. value-format="YYYY-MM-DD"
  18. style="width: 100%"
  19. allow-clear
  20. />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :span="12">
  24. <a-form-item
  25. label="询价项目(inquiry project)"
  26. v-bind="validateInfos.projectName"
  27. id="SaleInquiryFormForm-inquiryProject"
  28. name="inquiryProject"
  29. >
  30. <a-input-search
  31. v-model:value="formData.projectName"
  32. placeholder="请选择询价项目(inquiry project)"
  33. readonly
  34. allow-clear
  35. enter-button="Search"
  36. @search="onSearchProject"
  37. />
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="12">
  41. <a-form-item
  42. label="询价客户(inquiry customer)"
  43. v-bind="validateInfos.inquiryCustomer"
  44. id="SaleInquiryFormForm-inquiryCustomer"
  45. name="inquiryCustomer"
  46. >
  47. <!-- <JSelect v-model:value="formData.inquiryCustomer" :get-option-url="customerOption" :showField="showField" ></JSelect> -->
  48. <JSelectInput v-model:value="formData.inquiryCustomer" placeholder="请选择" :options="customerOption" disabled />
  49. </a-form-item>
  50. </a-col>
  51. <a-col :span="12">
  52. <a-form-item
  53. label="询价平台(inquiry platform)"
  54. v-bind="validateInfos.inquiryPlatform"
  55. id="SaleInquiryFormForm-inquiryPlatform"
  56. name="inquiryPlatform"
  57. >
  58. <JDictSelectTag v-model:value="formData.inquiryPlatform" placeholder="请选择" dictCode="inquiry_platform" />
  59. </a-form-item>
  60. </a-col>
  61. <a-col :span="12">
  62. <a-form-item label="客户联系人(inquiry liaisonId)" v-bind="validateInfos.liaisonId" id="SaleInquiryFormForm-liaisonId" name="liaisonId">
  63. <a-select v-model:value="formData.liaisonId" labelInValue @change="onChangeLiaison" allowClear>
  64. <a-select-option v-for="item in linkOption" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  65. </a-select>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :span="12">
  69. <a-form-item
  70. label="客户询价单号(customer inquiry number)"
  71. v-bind="validateInfos.customerInquiryNumber"
  72. id="SaleInquiryFormForm-customerInquiryNumber"
  73. name="customerInquiryNumber"
  74. >
  75. <a-input v-model:value="formData.customerInquiryNumber" placeholder="请输入客户询价单号(customer inquiry number)" allow-clear />
  76. </a-form-item>
  77. </a-col>
  78. <a-col :span="12">
  79. <a-form-item
  80. label="客户询价日期(customer inquiry time)"
  81. v-bind="validateInfos.inquiryTime"
  82. id="SaleInquiryFormForm-inquiryTime"
  83. name="inquiryTime"
  84. >
  85. <a-date-picker
  86. placeholder="请选择客户询价日期(customer inquiry time)"
  87. v-model:value="formData.inquiryTime"
  88. value-format="YYYY-MM-DD"
  89. style="width: 100%"
  90. allow-clear
  91. />
  92. </a-form-item>
  93. </a-col>
  94. <a-col :span="12">
  95. <a-form-item
  96. label="询价有效期(inquiry period)"
  97. v-bind="validateInfos.inquiryPeriodEnd"
  98. id="SaleInquiryFormForm-inquiryPeriodEnd"
  99. name="inquiryPeriodEnd"
  100. >
  101. <a-range-picker
  102. v-model:value="inquiryPeriod"
  103. :format="['YYYY-MM-DD', 'YYYY-MM-DD']"
  104. @change="onChangeInquiryPeriod"
  105. style="width: 100%"
  106. />
  107. </a-form-item>
  108. </a-col>
  109. <a-col :span="12">
  110. <a-form-item label="优先级(priority)" v-bind="validateInfos.priority" id="SaleInquiryFormForm-priority" name="priority">
  111. <JDictSelectTag v-model:value="formData.priority" placeholder="请选择" dictCode="priority" />
  112. </a-form-item>
  113. </a-col>
  114. <a-col :span="12">
  115. <a-form-item
  116. label="产品分类(production class)"
  117. v-bind="validateInfos.productionClass"
  118. id="SaleInquiryFormForm-productionClass"
  119. name="productionClass"
  120. >
  121. <JDictSelectTag
  122. v-model:value="formData.productionClass"
  123. placeholder=""
  124. dictCode="base_product_class,name,id,del_flag=0 and parent_id is null"
  125. page="false"
  126. showSearch
  127. />
  128. </a-form-item>
  129. </a-col>
  130. <a-col :span="12">
  131. <a-form-item label="机型(model)" v-bind="validateInfos.model" id="SaleInquiryFormForm-model" name="model">
  132. <JDictSelectTag v-model:value="formData.model" placeholder="请选择" dictCode="model_typer" showSearch />
  133. </a-form-item>
  134. </a-col>
  135. <a-col :span="12">
  136. <a-form-item label="厂家(maker)" v-bind="validateInfos.maker" id="SaleInquiryFormForm-maker" name="maker">
  137. <a-input v-model:value="formData.maker" placeholder="请输入厂家(maker)" allow-clear AutoComplete="off" />
  138. </a-form-item>
  139. </a-col>
  140. <a-col :span="12">
  141. <a-form-item
  142. label="销售部门(sale department)"
  143. v-bind="validateInfos.saleDepartment"
  144. id="SaleInquiryFormForm-saleDepartment"
  145. name="saleDepartment"
  146. >
  147. <a-input v-model:value="formData.saleDepartmentName" placeholder="" allow-clear disabled />
  148. </a-form-item>
  149. </a-col>
  150. <a-col :span="12">
  151. <a-form-item label="业务员(salesman)" v-bind="validateInfos.salesman" id="SaleInquiryFormForm-salesman" name="salesman">
  152. <a-input v-model:value="formData.salesmanName" placeholder="" allow-clear disabled />
  153. </a-form-item>
  154. </a-col>
  155. <a-col :span="12">
  156. <a-form-item
  157. label="采购询价组(procurement inquiry team)"
  158. v-bind="validateInfos.inquiryTeam"
  159. id="SaleInquiryFormForm-inquiryTeam"
  160. name="inquiryTeam"
  161. >
  162. <JSelectDept v-model:value="formData.inquiryTeam" :multiple="false" />
  163. </a-form-item>
  164. </a-col>
  165. <a-col :span="12">
  166. <a-form-item
  167. label="质量等级(quality grade)"
  168. v-bind="validateInfos.qualityGradeHead"
  169. id="SaleInquiryFormForm-qualityGradeHead"
  170. name="qualityGradeHead"
  171. >
  172. <JDictSelectTag
  173. v-model:value="formData.qualityGradeHead"
  174. placeholder="请选择"
  175. dictCode="quality_grade"
  176. @change="handleChangeQualityGrade"
  177. />
  178. </a-form-item>
  179. </a-col>
  180. <a-col :span="12">
  181. <a-form-item
  182. label="询价备注(inquiry notes)"
  183. v-bind="validateInfos.inquiryNotes"
  184. id="SaleInquiryFormForm-inquiryNotes"
  185. name="inquiryNotes"
  186. >
  187. <a-input v-model:value="formData.inquiryNotes" placeholder="请输入询价备注(inquiry notes)" allow-clear AutoComplete="off" />
  188. </a-form-item>
  189. </a-col>
  190. <a-col :span="12">
  191. <a-form-item label="附件(attachs)" v-bind="validateInfos.attachs" id="SaleInquiryFormForm-attachs" name="attachs">
  192. <JUpload v-model:value="formData.attachs" />
  193. </a-form-item>
  194. </a-col>
  195. </a-row>
  196. </a-form>
  197. </template>
  198. </JFormContainer>
  199. <!-- 子表单区域 -->
  200. <a-tabs v-model:activeKey="activeKey" animated style="padding: 24px; padding-top: 0px">
  201. <a-tab-pane tab="销售询价单 - 产品明细(product details)" key="saleInquiryFormProduct" :forceRender="true">
  202. <a-button type="primary" @click="selectProducts" style="margin-right: 1%; margin-bottom: 1%" :disabled="disabled">
  203. 选择产品(select product)</a-button
  204. >
  205. <a-button type="primary" @click="setNeed" style="margin-right: 1%" :disabled="disabled">
  206. 设置需要船检证书(set need ship inspection certificate)</a-button
  207. >
  208. <a-button type="primary" @click="setNotNeed" :disabled="disabled"> 设置不需要船检证书(set need not ship inspection certificate)</a-button>
  209. <j-vxe-table
  210. :keep-source="true"
  211. resizable
  212. ref="saleInquiryFormProductTableRef"
  213. :loading="saleInquiryFormProductTable.loading"
  214. :columns="saleInquiryFormProductTable.columns"
  215. :dataSource="saleInquiryFormProductTable.dataSource"
  216. :disabled="disabled"
  217. :rowNumber="true"
  218. :rowSelection="true"
  219. asyncRemove
  220. >
  221. <template #action="props">
  222. <a-popconfirm title="确定删除吗?" @confirm="handleDelete1(props)" v-if="!disabled">
  223. <a>删除(delete)</a>
  224. </a-popconfirm>
  225. </template>
  226. </j-vxe-table>
  227. </a-tab-pane>
  228. <a-tab-pane tab="销售询价单 - 船明细(ship details)" key="saleInquiryFormShip" :forceRender="true">
  229. <a-button type="primary" @click="selectShip" :disabled="disabled"> 选择船(select ship)</a-button>
  230. <j-vxe-table
  231. :keep-source="true"
  232. resizable
  233. ref="saleInquiryFormShipTableRef"
  234. :loading="saleInquiryFormShipTable.loading"
  235. :columns="saleInquiryFormShipTable.columns"
  236. :dataSource="saleInquiryFormShipTable.dataSource"
  237. :disabled="disabled"
  238. :rowNumber="true"
  239. :rowSelection="true"
  240. >
  241. <template #action="props">
  242. <a @click="viewAccessory(props)">查看配件信息(view accessory information)</a>
  243. <a-divider type="vertical" />
  244. <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)" v-if="!disabled">
  245. <a>删除(delete)</a>
  246. </a-popconfirm>
  247. </template>
  248. </j-vxe-table>
  249. </a-tab-pane>
  250. </a-tabs>
  251. <SelectShipSModal ref="SelectShipSModalRef" @select="addShip" />
  252. <BaseShipArchiveAccessoriesModal ref="BaseShipArchiveAccessoriesListRef" />
  253. <SelectPrpductModal ref="SelectPrpductModalRef" @select-product="addProduct" />
  254. <SelectProjectModal ref="SelectProjectModalRef" @select-project="addProject" />
  255. </a-spin>
  256. </template>
  257. <script lang="ts">
  258. import { defineComponent, ref, reactive, computed, toRaw } from 'vue';
  259. import { defHttp } from '/@/utils/http/axios';
  260. import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
  261. import {
  262. querySaleInquiryFormShipListByMainId,
  263. querySaleInquiryFormProductListByMainId,
  264. queryDataById,
  265. saveOrUpdate,
  266. LinkOption,
  267. } from '../SaleInquiryForm.api';
  268. import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  269. import { saleInquiryFormShipColumns, saleInquiryFormProductColumns } from '../SaleInquiryForm.data';
  270. import SelectShipSModal from '../../../publicComponents/SelectShipSModal.vue';
  271. import BaseShipArchiveAccessoriesModal from '../../../publicComponents/BaseShipArchiveAccessoriesModal.vue';
  272. import SelectPrpductModal from '../../../publicComponents/SelectPrpductModal.vue';
  273. import SelectProjectModal from '../../../publicComponents/SelectProjectModal.vue';
  274. import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  275. import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  276. import { JDictSelectTag, JSelect } from '/@/components/Form';
  277. import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  278. import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
  279. import { Form, message } from 'ant-design-vue';
  280. import { useUserStore } from '/@/store/modules/user';
  281. import dayjs from 'dayjs';
  282. const userStore = useUserStore();
  283. const useForm = Form.useForm;
  284. export default defineComponent({
  285. name: 'SaleInquiryFormForm',
  286. components: {
  287. JVxeTable,
  288. JFormContainer,
  289. SelectShipSModal,
  290. BaseShipArchiveAccessoriesModal,
  291. SelectPrpductModal,
  292. JUpload,
  293. SelectProjectModal,
  294. JDictSelectTag,
  295. JSelectInput,
  296. JSelectDept,
  297. },
  298. props: {
  299. formDisabled: {
  300. type: Boolean,
  301. default: false,
  302. },
  303. formData: { type: Object, default: () => {} },
  304. formBpm: { type: Boolean, default: true },
  305. },
  306. emits: ['success'],
  307. setup(props, { emit }) {
  308. const loading = ref(false);
  309. const formRef = ref();
  310. var linkOption = ref([]);
  311. var SelectPrpductModalRef = ref();
  312. var SelectProjectModalRef = ref();
  313. var inquiryPeriod = ref([]);
  314. const saleInquiryFormShipTableRef = ref();
  315. const saleInquiryFormShipTable = reactive<Record<string, any>>({
  316. loading: false,
  317. columns: saleInquiryFormShipColumns,
  318. dataSource: [],
  319. });
  320. const saleInquiryFormProductTableRef = ref();
  321. const saleInquiryFormProductTable = reactive<Record<string, any>>({
  322. loading: false,
  323. columns: saleInquiryFormProductColumns,
  324. dataSource: [],
  325. });
  326. var SelectShipSModalRef = ref();
  327. var BaseShipArchiveAccessoriesListRef = ref();
  328. const activeKey = ref('saleInquiryFormProduct');
  329. var customerOption = ref([]);
  330. const formData = reactive<Record<string, any>>({
  331. id: '',
  332. status: undefined,
  333. delFlag: undefined,
  334. otherStatus: '',
  335. billDate: dayjs(new Date()).format('YYYY-MM-DD'),
  336. billCode: '',
  337. inquiryProject: '',
  338. projectName: '',
  339. inquiryCustomer: '',
  340. customerName: '',
  341. inquiryPlatform: '',
  342. customerInquiryNumber: '',
  343. inquiryPeriodEnd: '',
  344. inquiryPeriodBegin: '',
  345. priority: '',
  346. productionClass: '',
  347. model: '',
  348. maker: '',
  349. saleDepartment: '',
  350. saleDepartmentName: '',
  351. salesman: '',
  352. salesmanName: '',
  353. inquiryTeam: '',
  354. attachs: '',
  355. inquiryNotes: '',
  356. inquiryTime: dayjs(new Date()).format('YYYY-MM-DD'),
  357. qualityGradeHead: '',
  358. liaisonId: '',
  359. liaisonInfo: '',
  360. });
  361. //表单验证
  362. const validatorRules = reactive({
  363. projectName: [{ required: true, message: '请选择询价项目(select project)' }],
  364. inquiryCustomer: [{ required: true, message: '请选择询价客户(select customer)' }],
  365. inquiryPlatform: [{ required: true, message: '请选择询价平台(select platform)' }],
  366. liaisonId: [{ required: true, message: '请选择客户联系人(select liaison)' }],
  367. customerInquiryNumber: [{ required: true, message: '请输入客户询价单号(input customerInquiryNumber)' }],
  368. inquiryTime: [{ required: true, message: '请选择客户询价日期(select inquiryTime)' }],
  369. model: [{ required: true, message: '请选择机型(model)' }],
  370. maker: [{ required: true, message: '请输入厂家(input maker)' }],
  371. qualityGradeHead: [{ required: true, message: '请选择质量等级(select qualityGradeHead)' }],
  372. });
  373. const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
  374. const dbData = {};
  375. const formItemLayout = {
  376. labelCol: { xs: { span: 24 }, sm: { span: 5 } },
  377. wrapperCol: { xs: { span: 24 }, sm: { span: 16 } },
  378. };
  379. // 表单禁用
  380. const disabled = computed(() => {
  381. if (props.formBpm === true) {
  382. if (props.formData.disabled === false) {
  383. return false;
  384. } else {
  385. return true;
  386. }
  387. }
  388. return props.formDisabled;
  389. });
  390. async function add() {
  391. await resetFields();
  392. saleInquiryFormShipTable.dataSource = [];
  393. saleInquiryFormProductTable.dataSource = [];
  394. activeKey.value = 'saleInquiryFormProduct';
  395. await getCustomerOptions();
  396. inquiryPeriod.value = [];
  397. formData.salesman = userStore.getUserInfo.username;
  398. formData.salesmanName = userStore.getUserInfo.realname;
  399. formData.saleDepartment = userStore.getUserInfo.orgCode;
  400. formData.saleDepartmentName = userStore.getUserInfo.orgName;
  401. }
  402. async function edit(row) {
  403. //主表数据
  404. await queryMainData(row.id);
  405. //子表数据
  406. const saleInquiryFormShipDataList = await querySaleInquiryFormShipListByMainId(row['id']);
  407. saleInquiryFormShipTable.dataSource = [...saleInquiryFormShipDataList];
  408. const saleInquiryFormProductDataList = await querySaleInquiryFormProductListByMainId(row['id']);
  409. saleInquiryFormProductTable.dataSource = [...saleInquiryFormProductDataList];
  410. getCustomerOptions();
  411. inquiryPeriod.value[0] = formData.inquiryPeriodBegin ? dayjs(formData.inquiryPeriodBegin, 'YYYY-MM-DD') : '';
  412. inquiryPeriod.value[1] = formData.inquiryPeriodEnd ? dayjs(formData.inquiryPeriodEnd, 'YYYY-MM-DD') : '';
  413. getLinkOptionsArr(formData.inquiryCustomer);
  414. }
  415. async function copy(data, id) {
  416. //主表数据
  417. await queryMainData(id);
  418. formData.id = '';
  419. formData.billCode = '';
  420. formData.submit = undefined;
  421. formData.inquiryProject = '';
  422. formData.projectName = '';
  423. formData.customerInquiryNumber = '';
  424. formData.attachs = '';
  425. formData.salesman = userStore.getUserInfo.username;
  426. formData.salesmanName = userStore.getUserInfo.realname;
  427. formData.saleDepartment = userStore.getUserInfo.orgCode;
  428. formData.saleDepartmentName = userStore.getUserInfo.orgName;
  429. //子表数据
  430. const saleInquiryFormShipDataList = await querySaleInquiryFormShipListByMainId(id);
  431. saleInquiryFormShipTable.dataSource = [...saleInquiryFormShipDataList];
  432. saleInquiryFormProductTable.dataSource = [...data];
  433. getCustomerOptions();
  434. inquiryPeriod.value[0] = formData.inquiryPeriodBegin ? dayjs(formData.inquiryPeriodBegin, 'YYYY-MM-DD') : '';
  435. inquiryPeriod.value[1] = formData.inquiryPeriodEnd ? dayjs(formData.inquiryPeriodEnd, 'YYYY-MM-DD') : '';
  436. getLinkOptionsArr(formData.inquiryCustomer);
  437. }
  438. async function queryMainData(id) {
  439. const row = await queryDataById(id);
  440. resetFields();
  441. const tmpData = {};
  442. Object.keys(formData).forEach((key) => {
  443. if (row.hasOwnProperty(key)) {
  444. tmpData[key] = row[key];
  445. }
  446. });
  447. //赋值
  448. Object.assign(formData, tmpData);
  449. }
  450. const { getSubFormAndTableData, transformData } = useValidateAntFormAndTable(activeKey, {
  451. saleInquiryFormShip: saleInquiryFormShipTableRef,
  452. saleInquiryFormProduct: saleInquiryFormProductTableRef,
  453. });
  454. async function getFormData() {
  455. try {
  456. // 触发表单验证
  457. await validate();
  458. } catch ({ errorFields }) {
  459. if (errorFields) {
  460. const firstField = errorFields[0];
  461. if (firstField) {
  462. formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
  463. }
  464. }
  465. return Promise.reject(errorFields);
  466. }
  467. return transformData(toRaw(formData));
  468. }
  469. async function submitForm() {
  470. const xTable = saleInquiryFormProductTableRef.value!.getXTable();
  471. const xTable2 = saleInquiryFormShipTableRef.value!.getXTable();
  472. if (xTable.data.length == 0) {
  473. message.warning('请添加产品明细');
  474. } else if (xTable2.data.length == 0) {
  475. message.warning('请添加船明细');
  476. } else {
  477. saleInquiryFormProductTableRef.value!.validateTable().then(async (errMap) => {
  478. if (errMap) {
  479. console.log('表单验证未通过:', { errMap });
  480. } else {
  481. const mainData = await getFormData();
  482. const subData = await getSubFormAndTableData();
  483. const values = Object.assign({}, dbData, mainData, subData);
  484. console.log('表单提交数据', values);
  485. const isUpdate = values.id ? true : false;
  486. await saveOrUpdate(values, isUpdate);
  487. //关闭弹窗
  488. emit('success');
  489. }
  490. });
  491. }
  492. }
  493. function setFieldsValue(values) {
  494. if (values) {
  495. Object.keys(values).map((k) => {
  496. formData[k] = values[k];
  497. });
  498. }
  499. }
  500. /**
  501. * 值改变事件触发-树控件回调
  502. * @param key
  503. * @param value
  504. */
  505. function handleFormChange(key, value) {
  506. formData[key] = value;
  507. }
  508. async function handleDelete(prop) {
  509. var xTable = saleInquiryFormShipTableRef.value!.getXTable();
  510. var newArray = [...xTable.data];
  511. newArray.splice(prop.rowIndex, 1);
  512. saleInquiryFormShipTable.dataSource = newArray;
  513. }
  514. async function handleDelete1(prop) {
  515. var xTable = saleInquiryFormProductTableRef.value!.getXTable();
  516. var newArray = [...xTable.data];
  517. newArray.splice(prop.rowIndex, 1);
  518. saleInquiryFormProductTable.dataSource = newArray;
  519. }
  520. function selectShip() {
  521. SelectShipSModalRef.value.getTable();
  522. }
  523. function addShip(data) {
  524. data.map((item) => {
  525. item.shipowner = item.relateCustomer;
  526. item.shipId = item.id;
  527. item.id = undefined;
  528. });
  529. var xTable = saleInquiryFormShipTableRef.value!.getXTable();
  530. var arr = xTable.data.concat(data);
  531. saleInquiryFormShipTable.dataSource = arr;
  532. }
  533. function addProduct(data) {
  534. data.map((item) => {
  535. item.productClass = item.classId_dictText;
  536. item.productCode = item.code;
  537. item.unit = item.measurementUnit;
  538. item.productId = item.id;
  539. item.qualityGrade = formData.qualityGradeHead !== '' ? formData.qualityGradeHead : '';
  540. item.id = undefined;
  541. item.notes = '';
  542. });
  543. var xTable = saleInquiryFormProductTableRef.value!.getXTable();
  544. var arrProduct = xTable.data.concat(data);
  545. saleInquiryFormProductTable.dataSource = arrProduct;
  546. }
  547. function addProject(data) {
  548. if (data.length == 0) {
  549. formData.inquiryProject = '';
  550. formData.projectName = '';
  551. } else {
  552. formData.inquiryProject = data[0].id;
  553. formData.projectName = data[0].code;
  554. formData.inquiryCustomer = data[0].customerId;
  555. formData.customerName = data[0].customerId_dictText;
  556. customerOption.value.map((item) => {
  557. if (item.value == data[0].customerId) {
  558. formData.priority = item.priority;
  559. }
  560. });
  561. getLinkOptionsArr(formData.inquiryCustomer);
  562. }
  563. }
  564. function getCustomerOptions() {
  565. let params = { pageSize: '-1', status: 1 };
  566. defHttp.get({ url: '/cuspCode/cuspCustomerProfile/list', params }, { isTransformResponse: false }).then((res) => {
  567. if (res) {
  568. customerOption.value = [];
  569. res.result.records.forEach((item) => {
  570. customerOption.value.push({
  571. label: item.name,
  572. value: item.id,
  573. priority: item.priority,
  574. });
  575. });
  576. }
  577. });
  578. }
  579. function viewAccessory(prop) {
  580. BaseShipArchiveAccessoriesListRef.value.getTable(prop.row);
  581. }
  582. function selectProducts() {
  583. SelectPrpductModalRef.value.getTable();
  584. }
  585. function setNeed() {
  586. const values = saleInquiryFormProductTableRef.value.getSelectionData();
  587. var arr = saleInquiryFormProductTableRef.value.getXTable();
  588. values.map((item) => {
  589. arr.data.map((event) => {
  590. if (item.id == event.id) {
  591. event.needShip = 1;
  592. }
  593. });
  594. saleInquiryFormProductTable.dataSource = [...arr.data];
  595. });
  596. }
  597. function setNotNeed() {
  598. const values = saleInquiryFormProductTableRef.value.getSelectionData();
  599. var arr = saleInquiryFormProductTableRef.value.getXTable();
  600. values.map((item) => {
  601. arr.data.map((event) => {
  602. if (item.id == event.id) {
  603. event.needShip = 0;
  604. }
  605. });
  606. saleInquiryFormProductTable.dataSource = [...arr.data];
  607. });
  608. }
  609. function onSearchProject() {
  610. SelectProjectModalRef.value.getTable('allowAdd');
  611. }
  612. function onChangeInquiryPeriod(data) {
  613. inquiryPeriod.value = data;
  614. formData.inquiryPeriodBegin = data[0].format('YYYY-MM-DD');
  615. formData.inquiryPeriodEnd = data[1].format('YYYY-MM-DD');
  616. }
  617. function handleChangeQualityGrade(data) {
  618. var xTable = saleInquiryFormProductTableRef.value!.getXTable(); //关键代码 如果不更新 重新加载表格即可
  619. xTable.data.map((item) => {
  620. item.qualityGrade = data;
  621. });
  622. saleInquiryFormProductTable.dataSource = xTable.data;
  623. }
  624. async function getLinkOptionsArr(customerId) {
  625. var obj = await LinkOption({ id: customerId });
  626. linkOption.value = obj;
  627. if (obj.lenght !== 0 && typeof obj === 'undefined') {
  628. formData.liaisonId = obj[0].id;
  629. formData.liaisonInfo = obj[0].name;
  630. }
  631. }
  632. function onChangeLiaison(data) {
  633. if (data && data !== undefined) {
  634. formData.liaisonId = data.key;
  635. formData.liaisonInfo = data.label[0].children;
  636. } else {
  637. formData.liaisonId = '';
  638. formData.liaisonInfo = '';
  639. }
  640. }
  641. return {
  642. saleInquiryFormShipTableRef,
  643. saleInquiryFormShipTable,
  644. saleInquiryFormProductTableRef,
  645. saleInquiryFormProductTable,
  646. validatorRules,
  647. validateInfos,
  648. activeKey,
  649. loading,
  650. formData,
  651. setFieldsValue,
  652. handleFormChange,
  653. formItemLayout,
  654. disabled,
  655. getFormData,
  656. submitForm,
  657. SelectShipSModalRef,
  658. add,
  659. edit,
  660. formRef,
  661. selectShip,
  662. addShip,
  663. addProduct,
  664. BaseShipArchiveAccessoriesListRef,
  665. viewAccessory,
  666. handleDelete,
  667. handleDelete1,
  668. selectProducts,
  669. setNeed,
  670. setNotNeed,
  671. SelectPrpductModalRef,
  672. SelectProjectModalRef,
  673. onSearchProject,
  674. addProject,
  675. getCustomerOptions,
  676. customerOption,
  677. inquiryPeriod,
  678. onChangeInquiryPeriod,
  679. handleChangeQualityGrade,
  680. copy,
  681. linkOption,
  682. getLinkOptionsArr,
  683. onChangeLiaison,
  684. };
  685. },
  686. });
  687. </script>
  688. <style lang="less" scoped>
  689. /** 时间和数字输入框样式 */
  690. :deep(.ant-input-number) {
  691. width: 100%;
  692. }
  693. :deep(.ant-calendar-picker) {
  694. width: 100%;
  695. }
  696. /deep/.vxe-table--body-wrapper {
  697. height: 100% !important;
  698. }
  699. /deep/.ant-modal-body {
  700. padding: 24px !important;
  701. }
  702. /deep/.ant-form-item {
  703. margin-bottom: 8px !important;
  704. }
  705. /deep/.vxe-cell--valid-error-msg {
  706. color: white !important;
  707. background-color: white !important;
  708. }
  709. </style>