addDialog.vue 25 KB

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