addDialog.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. v-if="visible"
  6. :visible.sync="visible"
  7. :title="title"
  8. :close-on-click-modal="false"
  9. :append-to-body="true"
  10. width="70%"
  11. :maxable="true"
  12. :resizable="true"
  13. @close="cancel"
  14. >
  15. <el-form
  16. ref="form"
  17. :model="form"
  18. :rules="rules"
  19. label-width="120px"
  20. class="el-form-box"
  21. >
  22. <headerTitle title="基本信息"></headerTitle>
  23. <el-row :gutter="12">
  24. <el-col :span="12">
  25. <el-form-item label="类型" prop="type">
  26. <el-select
  27. v-model="form.type"
  28. placeholder="请选择"
  29. style="width: 100%"
  30. @change="handleTypeChange"
  31. >
  32. <el-option
  33. v-for="item in typeOptions"
  34. :key="item.value"
  35. :label="item.label"
  36. :value="item.value"
  37. ></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="询价方名称" prop="contactName">
  41. <el-input
  42. clearable
  43. v-model="form.contactName"
  44. @click.native="handParent"
  45. :disabled="!!contactData.id || !!businessOpportunityData.id"
  46. placeholder="请输入"
  47. />
  48. </el-form-item>
  49. <el-form-item label="有无商机" prop="opportunityType">
  50. <el-select
  51. v-model="form.opportunityType"
  52. placeholder="请选择"
  53. style="width: 100%"
  54. @change="opportunityTypeChange"
  55. :disabled="!!businessOpportunityData.id"
  56. >
  57. <el-option
  58. v-for="item in opportunityTypeList"
  59. :key="item.value"
  60. :label="item.label"
  61. :value="item.value"
  62. >
  63. </el-option>
  64. </el-select>
  65. </el-form-item>
  66. <el-form-item
  67. label="关联商机"
  68. prop="opportunityId"
  69. :rules="[
  70. {
  71. required: form.opportunityType === 1 ? true : false,
  72. message: '请选择关联商机',
  73. trigger: 'change'
  74. }
  75. ]"
  76. >
  77. <el-select
  78. :disabled="
  79. form.opportunityType === 0 || !!businessOpportunityData.id
  80. "
  81. v-model="form.opportunityId"
  82. placeholder="请选择"
  83. style="width: 100%"
  84. @change="opportunityChange"
  85. >
  86. <el-option
  87. v-for="item in businessList"
  88. :key="item.id"
  89. :label="item.name"
  90. :value="item.id"
  91. >
  92. </el-option>
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item label="询价方联系人" prop="contactLinkName">
  96. <el-autocomplete
  97. v-model="form.contactLinkName"
  98. :fetch-suggestions="queryContactLink"
  99. @select="handleContactSelect"
  100. @input="handleContactInput"
  101. placeholder="请输入或选择询价方联系人"
  102. style="width: 100%"
  103. clearable
  104. ></el-autocomplete>
  105. </el-form-item>
  106. <el-form-item label="询价方电话" prop="contactTel">
  107. <el-input
  108. clearable
  109. :maxlength="20"
  110. v-model="form.contactTel"
  111. placeholder="请输入"
  112. />
  113. </el-form-item>
  114. <el-form-item label="询价方传真" prop="contactFax">
  115. <el-input
  116. clearable
  117. v-model="form.contactFax"
  118. placeholder="请输入"
  119. />
  120. </el-form-item>
  121. <el-form-item label=" 询价方Email" prop="contactEmail">
  122. <el-input
  123. clearable
  124. v-model="form.contactEmail"
  125. placeholder="请输入"
  126. />
  127. </el-form-item>
  128. <el-form-item label="询价方地址" prop="contactAddress">
  129. <el-input
  130. clearable
  131. v-model="form.contactAddress"
  132. placeholder="请输入"
  133. />
  134. </el-form-item>
  135. <el-form-item label="结算方式" prop="settlementMode">
  136. <DictSelection
  137. dictName="结算方式"
  138. clearable
  139. v-model="form.settlementMode"
  140. >
  141. </DictSelection>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="12">
  145. <el-form-item label="报价方名称" prop="quoteName">
  146. <el-input
  147. v-if="enterprisePage.length <= 1"
  148. clearable
  149. v-model="form.quoteName"
  150. placeholder="请输入"
  151. />
  152. <el-select
  153. v-if="enterprisePage.length > 1"
  154. style="width: 100%"
  155. v-model="form.quoteName"
  156. placeholder="请选择"
  157. @change="getEnterprise()"
  158. >
  159. <el-option
  160. v-for="item in enterprisePage"
  161. :key="item.id"
  162. :label="item.name"
  163. :value="item.name"
  164. >
  165. </el-option>
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item label="报价方联系人" prop="quoteLinkName">
  169. <el-input
  170. clearable
  171. v-model="form.quoteLinkName"
  172. @click.native="handHead()"
  173. placeholder="请输入"
  174. />
  175. </el-form-item>
  176. <el-form-item prop="quoteTel" label="报价方联系电话">
  177. <el-input clearable v-model="form.quoteTel" placeholder="请输入" />
  178. </el-form-item>
  179. <el-form-item prop="quoteFax" label="报价方传真">
  180. <el-input clearable v-model="form.quoteFax" placeholder="请输入" />
  181. </el-form-item>
  182. <el-form-item label="报价方Email" prop="quoteEmail">
  183. <el-input
  184. clearable
  185. v-model="form.quoteEmail"
  186. placeholder="请输入"
  187. />
  188. </el-form-item>
  189. <el-form-item label="报价方地址" prop="quoteAddress">
  190. <el-input
  191. clearable
  192. v-model="form.quoteAddress"
  193. placeholder="请输入"
  194. />
  195. </el-form-item>
  196. <el-form-item prop="askFile" label="附件">
  197. <fileMain v-model="form.askFile"></fileMain>
  198. </el-form-item>
  199. <el-form-item label="是否接受拆单" prop="acceptUnpack">
  200. <el-select
  201. v-model="form.acceptUnpack"
  202. placeholder="请选择"
  203. style="width: 100%"
  204. >
  205. <el-option
  206. v-for="item in acceptUnpackoptions"
  207. :key="item.value"
  208. :label="item.label"
  209. :value="item.value"
  210. >
  211. </el-option>
  212. </el-select>
  213. </el-form-item>
  214. </el-col>
  215. </el-row>
  216. <headerTitle title="报价单物品清单"></headerTitle>
  217. <inventoryTable
  218. ref="inventoryTable"
  219. :customerMark="form.customerMark"
  220. :isTemporary="true"
  221. :isDiscount="false"
  222. :cacheKeyUrl="cacheKeyUrl"
  223. :quoteType="form.type"
  224. :isHideProductionRequirements="true"
  225. ></inventoryTable>
  226. <!-- <el-row style="margin-top: 20px">
  227. <el-col :span="6">
  228. <el-form-item prop="taxRate" label="税率">
  229. <el-input clearable v-model="form.taxRate" placeholder="请输入">
  230. <template slot="append">%</template>
  231. </el-input>
  232. </el-form-item>
  233. </el-col>
  234. <el-col :span="6">
  235. <el-form-item prop="deliveryDate" label="交货日期">
  236. <el-date-picker
  237. v-model="form.deliveryDate"
  238. value-format="yyyy-MM-dd"
  239. placeholder="请选择交货日期"
  240. type="date"
  241. style="width: 100%"
  242. class="filter-item"
  243. ></el-date-picker>
  244. </el-form-item>
  245. </el-col>
  246. </el-row> -->
  247. </el-form>
  248. <div slot="footer" class="footer">
  249. <el-button type="primary" @click="save" v-click-once>保存</el-button>
  250. <el-button
  251. type="primary"
  252. @click="isNeed_process_is_close && save('sub')"
  253. v-click-once
  254. >提交</el-button
  255. >
  256. <el-button @click="cancel">返回</el-button>
  257. </div>
  258. <parentList
  259. ref="parentRef"
  260. classType="1"
  261. @changeParent="changeParent"
  262. ></parentList>
  263. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  264. <process-submit-dialog
  265. api-fun-name="quoteUpdateStatusAPI"
  266. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  267. v-if="processSubmitDialogFlag"
  268. ref="processSubmitDialogRef"
  269. @reload="reload"
  270. ></process-submit-dialog>
  271. </ele-modal>
  272. </template>
  273. <script>
  274. import { emailReg, phoneReg, numberReg, telReg } from 'ele-admin';
  275. import { acceptUnpackoptions } from '@/enum/dict';
  276. import inventoryTable from '@/BIZComponents/inventoryTable.vue';
  277. import { categoryData } from 'element-china-category-data';
  278. import fileUpload from '@/components/upload/fileUpload';
  279. import { cityData } from 'ele-admin/packages/utils/regions';
  280. import dictMixins from '@/mixins/dictMixins';
  281. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  282. import personSelect from '@/components/CommomSelect/person-select.vue';
  283. import parentList from '@/views/saleManage/contact/components/parentList.vue';
  284. import {
  285. getDetail,
  286. UpdateInformation,
  287. addInformation,
  288. submit
  289. } from '@/api/saleManage/quotation';
  290. import {
  291. getOpportunityDetail,
  292. isHasGeneratedQuoteAPI
  293. } from '@/api/saleManage/businessOpportunity';
  294. import { getTableList } from '@/api/saleManage/businessOpportunity';
  295. import { enterprisePage } from '@/api/contractManage/contractBook';
  296. import { listOrganizations } from '@/api/system/organization';
  297. import { getcontactlink } from '@/api/saleManage/businessFollow';
  298. import headList from '@/BIZComponents/user-select/user-select.vue';
  299. import { copyObj } from '@/utils/util';
  300. import { contactDetail, updateRelationStatus } from '@/api/saleManage/contact';
  301. // import fileMain from '@/components/addDoc/index.vue';
  302. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  303. export default {
  304. props: {
  305. categoryTreeList: Array,
  306. contactData: {
  307. default: () => {
  308. return {};
  309. }
  310. },
  311. businessOpportunityData: {
  312. default: () => {
  313. return {};
  314. }
  315. }
  316. },
  317. mixins: [dictMixins],
  318. components: {
  319. processSubmitDialog,
  320. // fileMain,
  321. fileUpload,
  322. headList,
  323. inventoryTable,
  324. deptSelect,
  325. parentList,
  326. personSelect
  327. },
  328. data() {
  329. let formDef = {
  330. id: '',
  331. acceptUnpack: 1,
  332. askFile: [],
  333. contactAddress: '',
  334. opportunityId: '',
  335. contactEmail: '',
  336. contactFax: '',
  337. contactId: '',
  338. contactLinkId: '',
  339. contactLinkName: '',
  340. contactName: '',
  341. contactTel: '',
  342. deliveryDate: '',
  343. settlementMode: '',
  344. settlementModeName: '',
  345. quoteAddress: '',
  346. quoteEmail: '',
  347. quoteFax: '',
  348. quoteLinkId: '',
  349. quoteLinkName: '',
  350. quoteName: '',
  351. quoteTel: '',
  352. taxRate: null,
  353. totalPrice: null,
  354. opportunityType: null,
  355. type: 1
  356. };
  357. return {
  358. fullscreen: false,
  359. cacheKeyUrl: 'eos-saleManage-quotation-inventoryTable',
  360. opportunityTypeList: [
  361. { label: '有', value: 1 },
  362. { label: '无', value: 0 }
  363. ],
  364. typeOptions: [
  365. { label: '产品销售', value: 1 },
  366. { label: '生产加工', value: 2 }
  367. ],
  368. payWayOptions: [],
  369. delDetailIds: [],
  370. linkNameOptions: [],
  371. acceptUnpackoptions,
  372. visible: false,
  373. processSubmitDialogFlag: false,
  374. title: '',
  375. row: {},
  376. activeName: 'base',
  377. formDef,
  378. form: copyObj(formDef),
  379. // removeBankList: [],
  380. // removeLinkList: [],
  381. tableBankData: [],
  382. tableLinkData: [],
  383. businessList: [], //商机列表
  384. rules: {
  385. // opportunityId: [
  386. // { required: true, message: '请选择关联商机', trigger: 'change' }
  387. // ],
  388. contactName: [
  389. { required: true, message: '请选择客户', trigger: 'change' }
  390. ],
  391. name: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
  392. contactLinkName: [
  393. { required: true, message: '请选择联系人', trigger: 'change' }
  394. ],
  395. acceptUnpack: [
  396. { required: true, message: '请选择是否接受', trigger: 'change' }
  397. ],
  398. type: [{ required: true, message: '请选择类型', trigger: 'change' }],
  399. contactTel: [
  400. // {
  401. // required: true,
  402. // pattern: phoneReg,
  403. // message: '请输入联系电话',
  404. // trigger: 'blur'
  405. // },
  406. {
  407. required: true, // 只保留必填校验
  408. message: '请输入联系电话', // 提示文字不变(仅提示必填)
  409. trigger: 'blur' // 触发时机(失去焦点时校验)
  410. }
  411. ],
  412. deliveryDate: [
  413. { required: true, message: '请选择交货日期', trigger: 'change' }
  414. ],
  415. settlementMode: [
  416. { required: true, message: '请选择结算方式', trigger: 'change' }
  417. ],
  418. quoteLinkName: [
  419. { required: true, message: '请输入报价方联系人', trigger: 'change' }
  420. ],
  421. quoteName: [
  422. { required: true, message: '请输入报价方名称', trigger: 'blur' }
  423. ],
  424. quoteTel: [
  425. {
  426. required: true,
  427. pattern: telReg,
  428. message: '请输入报价方联系电话',
  429. trigger: 'blur'
  430. }
  431. ],
  432. quoteEmail: [
  433. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  434. ],
  435. contactEmail: [
  436. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  437. ],
  438. taxRate: [
  439. { pattern: numberReg, message: '请输入数字', trigger: 'blur' }
  440. ]
  441. },
  442. businessId: '',
  443. options: {
  444. cityData,
  445. categoryData
  446. },
  447. // 提交状态
  448. loading: false,
  449. // 是否是修改
  450. isUpdate: false,
  451. // 组织机构树形结构数据
  452. groupTreeData: [],
  453. // 组织机构平铺数据
  454. groupData: [],
  455. enterprisePage: [],
  456. editType: ''
  457. };
  458. },
  459. created() {
  460. this.getGroupAll();
  461. this.getEnterprisePage();
  462. },
  463. methods: {
  464. handleTypeChange() {
  465. // 调用inventoryTable的putTableValue方法,传入空数组清空数据
  466. if (this.$refs.inventoryTable) {
  467. this.$refs.inventoryTable.putTableValue([]);
  468. }
  469. },
  470. opportunityTypeChange() {
  471. if (this.form.opportunityType === 0) {
  472. this.form.opportunityId = '';
  473. }
  474. },
  475. //获取详情
  476. async getDetailData(id) {
  477. this.businessId = id;
  478. this.loading = true;
  479. const data = await getDetail(id);
  480. this.loading = false;
  481. if (data) {
  482. this.$nextTick(() => {
  483. this.form = data;
  484. // if (data.askFile !== '') {
  485. // this.$set(this.form, 'askFile', [data?.askFile]);
  486. // }
  487. if (data.opportunityId) {
  488. this.form.opportunityType = 1;
  489. }
  490. this.$refs.inventoryTable &&
  491. this.$refs.inventoryTable.putTableValue(data);
  492. this.getLinkInfo(data.contactId);
  493. this.getBusinessList(data.contactId);
  494. });
  495. }
  496. },
  497. async opportunityChange(id) {
  498. //是否生成过报价单
  499. let res = await isHasGeneratedQuoteAPI(id);
  500. if (res) this.$message.warning('该商机已生成过报价单,请注意。');
  501. //获取台账库存
  502. getOpportunityDetail(id).then((res) => {
  503. if (res.productList.length > 0) {
  504. this.$refs.inventoryTable &&
  505. this.$refs.inventoryTable.putTableValue(res);
  506. }
  507. });
  508. },
  509. //更新联系人数据
  510. async getLinkInfo(contactId) {
  511. const data = await getcontactlink({ contactId });
  512. if (data && data?.length) {
  513. this.linkNameOptions = data;
  514. let firstLink =
  515. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  516. this.form = Object.assign({}, this.form, {
  517. contactLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  518. contactLinkName:
  519. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  520. contactTel:
  521. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone,
  522. contactEmail: firstLink.email || this.linkNameOptions[0]?.email
  523. });
  524. console.log(this.form);
  525. }
  526. },
  527. //获取客户的商机列表
  528. async getBusinessList(id) {
  529. if (!this.form.contactId)
  530. return this.$message.error('请先选择询价方名称');
  531. const data = await getTableList({
  532. pageNum: 1,
  533. size: 30,
  534. contactId: id,
  535. approvalStatus: 2,
  536. status: 1
  537. });
  538. this.businessList = data.list;
  539. },
  540. queryContactLink(queryString, callback) {
  541. const filtered = queryString
  542. ? this.linkNameOptions.filter((item) =>
  543. item.linkName.toLowerCase().includes(queryString.toLowerCase())
  544. )
  545. : this.linkNameOptions;
  546. callback(filtered.map((item) => ({ ...item, value: item.linkName })));
  547. },
  548. handleContactSelect(selectedItem) {
  549. this.form.contactLinkId = selectedItem.id;
  550. this.form.contactTel =
  551. selectedItem.mobilePhone || selectedItem.phone || '';
  552. this.form.contactEmail = selectedItem.email || '';
  553. },
  554. handleContactInput() {
  555. const isExist = this.linkNameOptions.some(
  556. (item) => item.linkName === this.form.contactLinkName
  557. );
  558. if (!isExist) {
  559. this.form.contactLinkId = ''; // 手动输入时无对应ID
  560. }
  561. },
  562. handHead() {
  563. let item = {
  564. id: this.form.quoteLinkId
  565. };
  566. this.$refs.headRef.open(item);
  567. },
  568. //选择报价方人回调
  569. changePersonel(obj, index) {
  570. this.$set(this.form, 'quoteLinkId', obj.id);
  571. this.$set(this.form, 'quoteLinkName', obj.name);
  572. this.$set(this.form, 'quoteTel', obj.phone);
  573. this.$set(this.form, 'quoteEmail', obj.email);
  574. },
  575. //选择客户回调
  576. async changeParent(obj, type) {
  577. const { base, other } = await contactDetail(obj.id);
  578. this.form = Object.assign({}, this.form, {
  579. contactId: base.id,
  580. contactName: base.name,
  581. contactAddress: other.addressName + other.address,
  582. contactLinkId: '',
  583. contactLinkName: '',
  584. contactEmail: '',
  585. contactTel: '',
  586. customerMark: base.serialNo
  587. });
  588. this.getLinkInfo(obj.id);
  589. this.getBusinessList(base.id);
  590. if (type == 'init') {
  591. return;
  592. }
  593. this.$nextTick(() => {
  594. if (this.form.opportunityType == 1) {
  595. this.$refs.inventoryTable.putTableValue([]);
  596. this.form.opportunityId = '';
  597. }
  598. this.$refs.inventoryTable.setCustomerMark(base.serialNo);
  599. });
  600. },
  601. handParent() {
  602. let item = {
  603. id: this.form.contactId
  604. };
  605. this.$refs.parentRef.open(item);
  606. },
  607. async open(type, row, contactCategoryId) {
  608. this.title = type === 'add' ? '新增' : type === 'copy' ? '复制' : '修改';
  609. this.editType = type;
  610. this.row = row;
  611. this.visible = true;
  612. if (this.groupData.length == 0) {
  613. await this.getGroupAll();
  614. }
  615. if (this.enterprisePage.length == 0) {
  616. await this.getEnterprisePage();
  617. }
  618. if (type == 'add') {
  619. let userInfo = this.$store.getters.user.info;
  620. this.isUpdate = false;
  621. userInfo.id = userInfo.userId;
  622. this.form.settlementMode = '3';
  623. this.changePersonel(userInfo);
  624. const enterprise = this.getCurrentEnterprise();
  625. if (enterprise) {
  626. this.getEnterprise(enterprise);
  627. }
  628. if (this.contactData.id) {
  629. this.changeParent({ id: this.contactData.id }, 'init');
  630. }
  631. if (this.businessOpportunityData.id) {
  632. this.form.opportunityId = this.businessOpportunityData.id;
  633. await this.opportunityChange(this.businessOpportunityData.id);
  634. this.form.opportunityType = 1;
  635. this.changeParent(
  636. { id: this.businessOpportunityData.contactId },
  637. 'init'
  638. );
  639. }
  640. if (row.id) {
  641. this.form.opportunityId = row.id;
  642. await this.opportunityChange(row.id);
  643. this.form.opportunityType = 1;
  644. this.changeParent({ id: row.contactId }, 'init');
  645. }
  646. } else {
  647. this.isUpdate = true;
  648. await this.getDetailData(row.id);
  649. }
  650. },
  651. getGroupAll() {
  652. return listOrganizations().then((list) => {
  653. this.groupData = list;
  654. });
  655. },
  656. getEnterprisePage() {
  657. return enterprisePage({
  658. pageNum: 1,
  659. size: 100
  660. }).then((res) => {
  661. this.enterprisePage = [];
  662. this.enterprisePage.push(...res.list);
  663. });
  664. },
  665. getCurrentEnterprise() {
  666. let groupId = this.$store.state.user.info?.groupId;
  667. const visitedGroupIds = [];
  668. while (groupId && !visitedGroupIds.includes(groupId)) {
  669. const enterprise = this.enterprisePage.find(
  670. (item) => item.groupId == groupId
  671. );
  672. if (enterprise) {
  673. return enterprise;
  674. }
  675. visitedGroupIds.push(groupId);
  676. const group = this.groupData.find((item) => item.id == groupId);
  677. groupId = group?.parentId;
  678. }
  679. return this.enterprisePage.length === 1 ? this.enterprisePage[0] : null;
  680. },
  681. getEnterprise(enterprise) {
  682. let data =
  683. enterprise ||
  684. this.enterprisePage.find((item) => item.name == this.form.quoteName);
  685. this.form.quoteName = data.name;
  686. // this.form.quoteTel = data.tel;
  687. this.form.quoteFax = data.fax;
  688. this.form.quoteAddress = data.address;
  689. },
  690. salesmanChange(val, info) {
  691. this.otherForm.salesmanName = info.name;
  692. },
  693. ifChiefChange(value, idx) {
  694. if (value === 1) {
  695. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  696. this.tableLinkData[idx].ifChief = 1;
  697. }
  698. },
  699. // getValidate() {
  700. // return new Promise((resolve, reject) => {
  701. // this.$refs.form.validate((valid) => {
  702. // if (!valid) {
  703. // reject(false);
  704. // } else {
  705. // resolve(true);
  706. // }
  707. // });
  708. // });
  709. // },
  710. getValidate() {
  711. return Promise.all([
  712. new Promise((resolve, reject) => {
  713. this.$refs.form.validate((valid) => {
  714. if (!valid) {
  715. reject(false);
  716. } else {
  717. resolve(true);
  718. }
  719. });
  720. }),
  721. new Promise((resolve, reject) => {
  722. this.$refs.inventoryTable.validateForm((valid) => {
  723. if (!valid) {
  724. reject(false);
  725. } else {
  726. resolve(true);
  727. }
  728. });
  729. })
  730. ]);
  731. },
  732. async save(type) {
  733. try {
  734. await this.getValidate();
  735. // 表单验证通过,执行保存操作
  736. this.loading = true;
  737. if (!this.isUpdate) {
  738. delete this.form.id;
  739. }
  740. let settlementModeName = this.getDictValue(
  741. '结算方式',
  742. this.form.settlementMode
  743. );
  744. let commitData = Object.assign({}, this.form, {
  745. settlementModeName,
  746. quoteProductList: this.$refs.inventoryTable.getTableValue(),
  747. totalPrice: this.$refs.inventoryTable.getPrice()[0]
  748. });
  749. if (this.isUpdate && this.editType == 'edit') {
  750. UpdateInformation(commitData)
  751. .then((res) => {
  752. this.loading = false;
  753. updateRelationStatus([this.form.contactId]);
  754. if (type === 'sub') {
  755. this.quotationSubmit(res);
  756. return;
  757. }
  758. this.$message.success('修改成功');
  759. this.cancel();
  760. this.$emit('done');
  761. })
  762. .catch((e) => {
  763. //this.loading = false;
  764. });
  765. } else {
  766. if (this.editType == 'copy') {
  767. console.log('copy~~~~~~')
  768. // 删除quoteProductList中每个对象的id属性
  769. commitData.quoteProductList = commitData.quoteProductList.map(({ id, ...rest }) => rest);
  770. // 删除commitData本身的id属性
  771. delete commitData.id;
  772. }
  773. console.log('commitData~~~~~~~~', commitData)
  774. addInformation(commitData)
  775. .then((res) => {
  776. this.loading = false;
  777. updateRelationStatus([this.form.contactId]);
  778. if (type === 'sub') {
  779. this.quotationSubmit(res);
  780. return;
  781. }
  782. this.$message.success('新增成功');
  783. this.cancel();
  784. this.$emit('done');
  785. })
  786. .catch((e) => {
  787. //this.loading = false;
  788. });
  789. }
  790. } catch (error) {
  791. console.log(error);
  792. // 表单验证未通过,不执行保存操作
  793. }
  794. },
  795. async quotationSubmit(res) {
  796. const data = await getDetail(this.businessId || res);
  797. this.processSubmitDialogFlag = true;
  798. this.$nextTick(() => {
  799. let params = {
  800. businessId: this.businessId || res,
  801. businessKey: 'quote_approve',
  802. formCreateUserId: data.createUserId,
  803. variables: {
  804. businessCode: data.code,
  805. businessName: data.contactName,
  806. businessType: '报价单'
  807. }
  808. // callBackMethodType : '1',
  809. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  810. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  811. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  812. // miniHandle : '',
  813. // miniView : '',
  814. };
  815. this.$refs.processSubmitDialogRef.init(params);
  816. });
  817. // submit({
  818. // businessId: this.businessId || res
  819. // }).then((res) => {
  820. // this.cancel();
  821. // this.$emit('done');
  822. // });
  823. },
  824. reload() {
  825. this.cancel();
  826. this.$emit('done');
  827. },
  828. cancel() {
  829. this.$nextTick(() => {
  830. this.activeName = 'base';
  831. // 关闭后,销毁所有的表单数据
  832. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  833. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  834. this.form = copyObj(this.formDef);
  835. this.visible = false;
  836. });
  837. }
  838. }
  839. };
  840. </script>
  841. <style scoped lang="scss">
  842. .TotalAmount {
  843. font-size: 16px;
  844. padding-right: 30px;
  845. }
  846. </style>