PriceSheet.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  4. <template #seller>
  5. <div style="width: 100%">
  6. <el-form-item prop="sellCorporationId">
  7. <el-select v-model="formData.data.sellCorporationId" style="width: 100%" disabled>
  8. <el-option v-for="item in corporationList" :key="item.value" :label="item.label" :value="item.value" />
  9. </el-select>
  10. </el-form-item>
  11. <el-row style="margin-top: 20px; width: 100%">
  12. <el-col :span="8">
  13. <el-form-item label="地址" prop="sellCountryName">
  14. <el-input v-model="formData.data.sellCountryName" placeholder="请输入国家" />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="8">
  18. <el-form-item label=" " prop="sellProvinceName">
  19. <el-input v-model="formData.data.sellProvinceName" placeholder="请输入省/州" />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label=" " prop="sellCityName">
  24. <el-input v-model="formData.data.sellCityName" placeholder="请输入城市" />
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. <el-row style="margin-top: 20px; width: 100%">
  29. <el-col :span="24">
  30. <el-form-item prop="sellAddress">
  31. <el-input v-model="formData.data.sellAddress" type="textarea"> </el-input>
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. <el-row style="margin-top: 20px; width: 100%">
  36. <el-col :span="8">
  37. <el-form-item label="联系人" prop="sellContactName">
  38. <el-input v-model="formData.data.sellContactName" placeholder="请输入联系人" />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="16">
  42. <el-form-item label=" " prop="sellContactNumber">
  43. <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </div>
  48. </template>
  49. <template #buyer>
  50. <div style="width: 100%">
  51. <div style="width: 100%">
  52. <el-form-item prop="buyCorporationId">
  53. <el-select v-model="formData.data.buyCorporationId" style="width: 100%" @change="changeCustomer">
  54. <el-option v-for="item in customerList" :key="item.value" :label="item.label" :value="item.value" />
  55. </el-select>
  56. </el-form-item>
  57. <el-row style="margin-top: 20px; width: 100%">
  58. <el-col :span="6">
  59. <el-form-item label="地址" prop="countryId">
  60. <el-select v-model="formData.data.countryId" placeholder="国家" filterable @change="(val) => getCityData(val, '20', true)">
  61. <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id"> </el-option>
  62. </el-select>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="6">
  66. <el-form-item label=" " prop="provinceName">
  67. <selectCity
  68. placeholder="省/洲"
  69. @change="(val) => getCityData(val, '30', true)"
  70. addressId="provinceId"
  71. addressName="provinceName"
  72. v-model="formData.data"
  73. :data="provinceData">
  74. </selectCity>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="6">
  78. <el-form-item label=" " prop="cityName">
  79. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData"> </selectCity>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="6">
  83. <el-form-item label=" " prop="buyPostalCode">
  84. <el-input v-model="formData.data.buyPostalCode" placeholder="请输入邮编" />
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <el-row style="margin-top: 20px; width: 100%">
  89. <el-col :span="24">
  90. <el-form-item prop="buyAddress">
  91. <el-input v-model="formData.data.buyAddress" type="textarea"> </el-input>
  92. </el-form-item>
  93. </el-col>
  94. </el-row>
  95. <el-row style="margin-top: 20px; width: 100%">
  96. <el-col :span="8">
  97. <el-form-item label="联系人" prop="buyContactName">
  98. <el-autocomplete
  99. v-model="formData.data.buyContactName"
  100. :fetch-suggestions="querySearchPerson"
  101. clearable
  102. class="inline-input w-50"
  103. placeholder="请输入联系人"
  104. @select="handlePerson">
  105. </el-autocomplete>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="16">
  109. <el-form-item label=" " prop="buyContactNumber">
  110. <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. </div>
  115. </div>
  116. </template>
  117. <template #payment>
  118. <div style="width: 100%">
  119. <el-row style="margin-top: 20px; width: 100%">
  120. <el-col :span="6">
  121. <el-form-item label="币种" prop="currency">
  122. <el-select v-model="formData.data.currency" placeholder="请选择币种" style="width: 100%">
  123. <el-option v-for="item in accountCurrency" :key="item.value" :label="item.label" :value="item.value" />
  124. </el-select>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="6">
  128. <el-form-item label="付款方式" prop="paymentMethod">
  129. <el-select v-model="formData.data.paymentMethod" placeholder="请选择付款方式" style="width: 100%">
  130. <el-option v-for="item in fundsPaymentMethod" :key="item.value" :label="item.label" :value="item.value" />
  131. </el-select>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="6">
  135. <el-form-item label="预付比例 (%)" prop="advanceRatio">
  136. <el-input-number
  137. onmousewheel="return false;"
  138. v-model="formData.data.advanceRatio"
  139. placeholder="请输入预付比例"
  140. style="width: 100%"
  141. :precision="2"
  142. :controls="false"
  143. :min="0"
  144. :max="100" />
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. <el-row style="margin-top: 20px; width: 100%">
  149. <el-col :span="18">
  150. <el-form-item label="付款条件" prop="remark">
  151. <el-input v-model="formData.data.remark" :rows="2" type="textarea" placeholder="请输入付款条件" />
  152. </el-form-item>
  153. </el-col>
  154. </el-row>
  155. </div>
  156. </template>
  157. <template #delivery>
  158. <div style="width: 100%">
  159. <el-row style="margin-top: 20px; width: 100%">
  160. <el-col :span="6">
  161. <el-form-item label="报价有效期 (天)" prop="effective">
  162. <el-input-number
  163. onmousewheel="return false;"
  164. v-model="formData.data.effective"
  165. placeholder="请输入有效期"
  166. style="width: 100%"
  167. :precision="0"
  168. :controls="false"
  169. :min="0" />
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="6">
  173. <el-form-item label="交货期限" prop="deliveryTime">
  174. <el-date-picker v-model="formData.data.deliveryTime" type="date" placeholder="请选择交货期限" value-format="YYYY-MM-DD" />
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="6">
  178. <el-form-item label="运输方式" prop="transportMethod">
  179. <el-select v-model="formData.data.transportMethod" placeholder="请选择运输方式" style="width: 100%">
  180. <el-option v-for="item in shippingMethod" :key="item.value" :label="item.label" :value="item.value" />
  181. </el-select>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="6">
  185. <el-form-item label="运输说明" prop="transportRemark">
  186. <el-input v-model="formData.data.transportRemark" placeholder="请输入运输说明" />
  187. </el-form-item>
  188. </el-col>
  189. </el-row>
  190. </div>
  191. </template>
  192. <template #commodity>
  193. <div style="width: 100%">
  194. <el-button type="primary" @click="openProductCompany = true" plain>标准产品库</el-button>
  195. <el-button type="primary" @click="clickCustomerProduct()" plain>客户产品库</el-button>
  196. <el-table :data="formData.data.quotationProductList" style="width: 100%; margin-top: 16px">
  197. <el-table-column label="商品图片" width="80">
  198. <template #default="{ row }">
  199. <div v-if="row.productId">
  200. <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  201. </div>
  202. <div v-else></div>
  203. </template>
  204. </el-table-column>
  205. <el-table-column label="商品名称" min-width="180">
  206. <template #default="{ row, $index }">
  207. <div style="width: 100%">
  208. <el-form-item
  209. :prop="'quotationProductList.' + $index + '.productName'"
  210. :rules="rules.productName"
  211. :inline-message="true"
  212. class="shrinkPadding">
  213. <el-input v-model="row.productName" placeholder="请输入商品名称" />
  214. </el-form-item>
  215. </div>
  216. </template>
  217. </el-table-column>
  218. <el-table-column label="尺寸 cm*cm*cm" width="140">
  219. <template #default="{ row, $index }">
  220. <div style="width: 100%">
  221. <el-form-item
  222. :prop="'quotationProductList.' + $index + '.productModel'"
  223. :rules="rules.productModel"
  224. :inline-message="true"
  225. class="shrinkPadding">
  226. <el-input v-model="row.productModel" placeholder="请输入" />
  227. </el-form-item>
  228. </div>
  229. </template>
  230. </el-table-column>
  231. <el-table-column label="数量" width="130">
  232. <template #default="{ row, $index }">
  233. <div style="width: 100%">
  234. <el-form-item :prop="'quotationProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" class="shrinkPadding">
  235. <el-input-number
  236. onmousewheel="return false;"
  237. v-model="row.quantity"
  238. placeholder="请输入"
  239. style="width: 100%"
  240. :precision="0"
  241. :controls="false"
  242. :min="0"
  243. @change="calculationAmount()" />
  244. </el-form-item>
  245. </div>
  246. </template>
  247. </el-table-column>
  248. <el-table-column label="单价" width="140">
  249. <template #default="{ row, $index }">
  250. <div style="width: 100%">
  251. <el-form-item :prop="'quotationProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true" class="shrinkPadding">
  252. <el-input-number
  253. onmousewheel="return false;"
  254. v-model="row.price"
  255. placeholder="请输入"
  256. style="width: 100%"
  257. :precision="2"
  258. :controls="false"
  259. :min="0"
  260. @change="calculationAmount()" />
  261. </el-form-item>
  262. </div>
  263. </template>
  264. </el-table-column>
  265. <el-table-column label="贸易方式" width="140">
  266. <template #default="{ row, $index }">
  267. <div style="width: 100%">
  268. <el-form-item
  269. :prop="'quotationProductList.' + $index + '.tradeMethods'"
  270. :rules="rules.tradeMethods"
  271. :inline-message="true"
  272. class="shrinkPadding">
  273. <el-select v-model="row.tradeMethods" placeholder="请选择" style="width: 100%">
  274. <el-option v-for="item in tradeMethods" :key="item.value" :label="item.label" :value="item.value" />
  275. </el-select>
  276. </el-form-item>
  277. </div>
  278. </template>
  279. </el-table-column>
  280. <el-table-column label="包装方式" width="180">
  281. <template #default="{ row, $index }">
  282. <div style="width: 100%">
  283. <el-form-item :prop="'quotationProductList.' + $index + '.packMethod'" :rules="rules.packMethod" :inline-message="true" class="shrinkPadding">
  284. <el-input v-model="row.packMethod" placeholder="请输入" />
  285. </el-form-item>
  286. </div>
  287. </template>
  288. </el-table-column>
  289. <el-table-column prop="amount" :label="'金额 ( ' + formData.data.currency + ' )'" width="130" />
  290. <el-table-column label="操作" width="60" align="center" fixed="right">
  291. <template #default="{ $index }">
  292. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  293. </template>
  294. </el-table-column>
  295. </el-table>
  296. </div>
  297. </template>
  298. <template #otherCharge>
  299. <div style="width: 100%">
  300. <el-button type="primary" @click="clickAdd()">添加行</el-button>
  301. <el-table :data="formData.data.quotationPayList" style="width: 100%; margin-top: 16px">
  302. <el-table-column label="收费项目" width="220">
  303. <template #default="{ row, $index }">
  304. <div style="width: 100%">
  305. <el-form-item :prop="'quotationPayList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true">
  306. <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50" placeholder="请输入收费项目" />
  307. </el-form-item>
  308. </div>
  309. </template>
  310. </el-table-column>
  311. <el-table-column label="备注">
  312. <template #default="{ row, $index }">
  313. <div style="width: 100%">
  314. <el-form-item :prop="'quotationPayList.' + $index + '.remark'">
  315. <el-input v-model="row.remark" placeholder="请输入备注" />
  316. </el-form-item>
  317. </div>
  318. </template>
  319. </el-table-column>
  320. <el-table-column :label="'金额 ( ' + formData.data.currency + ' )'" width="130">
  321. <template #default="{ row, $index }">
  322. <div style="width: 100%">
  323. <el-form-item :prop="'quotationPayList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true" class="shrinkPadding">
  324. <el-input-number
  325. onmousewheel="return false;"
  326. v-model="row.amount"
  327. placeholder="请输入金额"
  328. style="width: 100%"
  329. :precision="2"
  330. :controls="false"
  331. :min="0"
  332. @change="totalAmount()" />
  333. </el-form-item>
  334. </div>
  335. </template>
  336. </el-table-column>
  337. <el-table-column label="操作" width="60" align="center" fixed="right">
  338. <template #default="{ $index }">
  339. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  340. </template>
  341. </el-table-column>
  342. </el-table>
  343. </div>
  344. </template>
  345. <template #offerMoney>
  346. <div style="width: 100%; display: flex">
  347. <div style="width: calc(100% - 190px)"></div>
  348. <div style="width: 130px; padding: 0 12px">
  349. <el-form-item label="合同总金额" prop="amount" class="shrinkPadding">
  350. <el-input v-model="formData.data.amount" placeholder="合同总金额" disabled />
  351. </el-form-item>
  352. </div>
  353. </div>
  354. </template>
  355. </byForm>
  356. <el-dialog v-if="openProductCompany" v-model="openProductCompany" title="公司产品库" width="90%" append-to-body>
  357. <CompanyProduct :selectStatus="true" @selectProduct="selectProduct"></CompanyProduct>
  358. </el-dialog>
  359. <el-dialog v-if="openProductCustomer" v-model="openProductCustomer" title="客户产品库" width="90%" append-to-body>
  360. <CustomerProduct :selectStatus="true" :buyCorporationId="formData.data.buyCorporationId" @selectProduct="selectProduct"></CustomerProduct>
  361. </el-dialog>
  362. </div>
  363. </template>
  364. <script setup>
  365. import byForm from "@/components/byForm/index";
  366. import CompanyProduct from "@/views/EHSD/productLibrary/companyProduct/index";
  367. import CustomerProduct from "@/views/EHSD/productLibrary/customerProduct/index";
  368. import { ElMessage } from "element-plus";
  369. import selectCity from "@/components/selectCity/index.vue";
  370. import { useRoute } from "vue-router";
  371. const route = useRoute();
  372. const { proxy } = getCurrentInstance();
  373. const innerMethod = ref([]);
  374. const outsideMethod = ref([]);
  375. const accountCurrency = ref([]);
  376. const fundsPaymentMethod = ref([]);
  377. const tradeMethods = ref([]);
  378. const shippingMethod = ref([]);
  379. const templateList = ref([]);
  380. const corporationList = ref([]);
  381. const customerList = ref([]);
  382. const countryData = ref([]);
  383. const provinceData = ref([]);
  384. const cityData = ref([]);
  385. const customerUserList = ref([]);
  386. const openProductCompany = ref(false);
  387. const openProductCustomer = ref(false);
  388. const formData = reactive({
  389. data: {
  390. currency: "¥",
  391. amount: undefined,
  392. quotationProductList: [],
  393. quotationPayList: [],
  394. },
  395. });
  396. const submit = ref(null);
  397. const judgeStatus = () => {
  398. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  399. let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
  400. if (data && data.length > 0) {
  401. return true;
  402. }
  403. }
  404. return false;
  405. };
  406. const formOption = reactive({
  407. inline: true,
  408. labelWidth: 100,
  409. itemWidth: 100,
  410. rules: [],
  411. disabled: false
  412. });
  413. const formConfig = computed(() => {
  414. return [
  415. {
  416. type: "title",
  417. title: "合同模板",
  418. label: "",
  419. },
  420. {
  421. type: "select",
  422. label: "选择合同模板",
  423. prop: "contractTemplateId",
  424. data: templateList.value,
  425. fn: (val) => {
  426. changeTemplate(val);
  427. },
  428. },
  429. {
  430. type: "slot",
  431. slotName: "seller",
  432. label: "卖方信息",
  433. itemWidth: 50,
  434. },
  435. {
  436. type: "slot",
  437. slotName: "buyer",
  438. label: "买方信息",
  439. itemWidth: 50,
  440. },
  441. {
  442. type: "slot",
  443. slotName: "payment",
  444. label: "付款信息",
  445. },
  446. {
  447. type: "slot",
  448. slotName: "delivery",
  449. label: "交付信息",
  450. },
  451. {
  452. type: "slot",
  453. slotName: "commodity",
  454. label: "商品信息",
  455. },
  456. {
  457. type: "slot",
  458. slotName: "otherCharge",
  459. label: "其他收费项目",
  460. },
  461. {
  462. type: "slot",
  463. slotName: "offerMoney",
  464. },
  465. ];
  466. });
  467. const rules = ref({
  468. contractTemplateId: [{ required: true, message: "请选择合同模板", trigger: "change" }],
  469. buyCorporationId: [{ required: true, message: "请选择公司", trigger: "change" }],
  470. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  471. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  472. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  473. buyContactName: [{ required: true, message: "请输入联系人", trigger: ["change", "blur"] }],
  474. buyContactNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  475. productName: [{ required: true, message: "请输入商品名称", trigger: "blur" }],
  476. productModel: [{ required: true, message: "请输入尺寸 cm*cm*cm", trigger: "blur" }],
  477. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  478. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  479. packMethod: [{ required: true, message: "请输入包装方式", trigger: "blur" }],
  480. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  481. payName: [{ required: true, message: "请输入收费项目", trigger: ["change", "blur"] }],
  482. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  483. effective: [{ required: true, message: "请输入报价有效期", trigger: "blur" }],
  484. deliveryTime: [{ required: true, message: "请选择交货期限", trigger: "change" }],
  485. paymentMethod: [{ required: true, message: "请选择付款方式", trigger: "change" }],
  486. advanceRatio: [{ required: true, message: "请输入预付比例", trigger: "blur" }],
  487. tradeMethods: [{ required: true, message: "请选择贸易方式", trigger: "change" }],
  488. transportMethod: [{ required: true, message: "请选择运输方式", trigger: "change" }],
  489. transportRemark: [{ required: true, message: "请输入运输说明", trigger: "blur" }],
  490. remark: [{ required: true, message: "请输入付款条件", trigger: "blur" }],
  491. });
  492. const getDict = () => {
  493. proxy
  494. .getDictOne([
  495. "inner_packaging_method_ehsd",
  496. "outside_packaging_method_ehsd",
  497. "account_currency",
  498. "funds_payment_method",
  499. "trade_methods",
  500. "shipping_method",
  501. ])
  502. .then((res) => {
  503. innerMethod.value = res["inner_packaging_method_ehsd"].map((x) => ({
  504. label: x.dictValue,
  505. value: x.dictKey,
  506. }));
  507. outsideMethod.value = res["outside_packaging_method_ehsd"].map((x) => ({
  508. label: x.dictValue,
  509. value: x.dictKey,
  510. }));
  511. accountCurrency.value = res["account_currency"].map((x) => ({
  512. label: x.dictValue,
  513. value: x.dictKey,
  514. }));
  515. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  516. label: x.dictValue,
  517. value: x.dictKey,
  518. }));
  519. tradeMethods.value = res["trade_methods"].map((x) => ({
  520. label: x.dictValue,
  521. value: x.dictKey,
  522. }));
  523. shippingMethod.value = res["shipping_method"].map((x) => ({
  524. label: x.dictValue,
  525. value: x.dictKey,
  526. }));
  527. });
  528. proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  529. templateList.value = res.rows.map((item) => {
  530. return {
  531. ...item,
  532. label: item.templateName,
  533. value: item.id,
  534. };
  535. });
  536. });
  537. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  538. corporationList.value = res.rows.map((item) => {
  539. return {
  540. ...item,
  541. label: item.name,
  542. value: item.id,
  543. };
  544. });
  545. });
  546. proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  547. customerList.value = res.rows.map((item) => {
  548. return {
  549. ...item,
  550. label: item.name,
  551. value: item.id,
  552. };
  553. });
  554. });
  555. };
  556. getDict();
  557. const changeTemplate = (val) => {
  558. formData.data.sellCorporationId = "";
  559. formData.data.sellContactName = "";
  560. formData.data.sellContactNumber = "";
  561. formData.data.sellCountryName = "";
  562. formData.data.sellProvinceName = "";
  563. formData.data.sellCityName = "";
  564. formData.data.sellAddress = "";
  565. if (val) {
  566. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  567. formData.data.sellCorporationId = res.corporationId;
  568. if (res.corporationId) {
  569. proxy.post("/corporation/detail", { id: res.corporationId }).then((detailCorporation) => {
  570. proxy.post("/customizeArea/list", { parentId: "0" }).then((resCountry) => {
  571. let sellCountryData = resCountry.filter((item) => item.id === detailCorporation.countryId);
  572. if (sellCountryData && sellCountryData.length > 0) {
  573. formData.data.sellCountryName = sellCountryData[0].chineseName;
  574. } else {
  575. formData.data.sellCountryName = "";
  576. }
  577. });
  578. if (detailCorporation.countryId) {
  579. proxy.post("/customizeArea/list", { parentId: detailCorporation.countryId }).then((resProvince) => {
  580. let sellProvinceData = resProvince.filter((item) => item.id === detailCorporation.provinceId);
  581. if (sellProvinceData && sellProvinceData.length > 0) {
  582. formData.data.sellProvinceName = sellProvinceData[0].name;
  583. } else {
  584. formData.data.sellProvinceName = "";
  585. }
  586. });
  587. } else {
  588. formData.data.sellProvinceName = "";
  589. }
  590. if (detailCorporation.provinceId) {
  591. proxy.post("/customizeArea/list", { parentId: detailCorporation.provinceId }).then((resCity) => {
  592. let sellCityData = resCity.filter((item) => item.id === detailCorporation.cityId);
  593. if (sellCityData && sellCityData.length > 0) {
  594. formData.data.sellCityName = sellCityData[0].name;
  595. } else {
  596. formData.data.sellCityName = "";
  597. }
  598. });
  599. } else {
  600. formData.data.sellCityName = "";
  601. }
  602. formData.data.sellAddress = detailCorporation.address;
  603. });
  604. }
  605. formData.data.sellContactName = res.contactName;
  606. formData.data.sellContactNumber = res.contactNumber;
  607. });
  608. }
  609. };
  610. const getCityData = (id, type, isChange) => {
  611. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  612. if (type === "20") {
  613. provinceData.value = res;
  614. if (isChange) {
  615. formData.data.provinceId = "";
  616. formData.data.provinceName = "";
  617. formData.data.cityId = "";
  618. formData.data.cityName = "";
  619. }
  620. } else if (type === "30") {
  621. cityData.value = res;
  622. if (isChange) {
  623. formData.data.cityId = "";
  624. formData.data.cityName = "";
  625. }
  626. } else {
  627. countryData.value = res;
  628. }
  629. });
  630. };
  631. getCityData("0");
  632. const changeCustomer = (val) => {
  633. formData.data.quotationProductList = [];
  634. formData.data.customerName = "";
  635. formData.data.customerTel = "";
  636. if (val) {
  637. proxy.post("/customer/detail", { id: val }).then(
  638. (res) => {
  639. if (res.customerUserList && res.customerUserList.length > 0) {
  640. formData.data.buyContactName = res.customerUserList[0].name;
  641. if (res.customerUserList[0].contactJson) {
  642. let contactJson = JSON.parse(res.customerUserList[0].contactJson);
  643. if (contactJson && contactJson.length > 0) {
  644. formData.data.buyContactNumber = contactJson[0].contactNo;
  645. }
  646. }
  647. customerUserList.value = res.customerUserList.map((item) => {
  648. return {
  649. ...item,
  650. value: item.name,
  651. };
  652. });
  653. }
  654. formData.data.countryId = res.countryId;
  655. formData.data.provinceId = res.provinceId;
  656. formData.data.cityId = res.cityId;
  657. formData.data.buyPostalCode = res.zipCode;
  658. formData.data.buyAddress = res.address;
  659. getCityData(formData.data.countryId, "20");
  660. if (formData.data.provinceId) {
  661. getCityData(formData.data.provinceId, "30");
  662. }
  663. },
  664. (err) => {
  665. console.log(err);
  666. formData.data.countryId = "";
  667. formData.data.provinceId = "";
  668. formData.data.cityId = "";
  669. formData.data.buyPostalCode = "";
  670. formData.data.buyAddress = "";
  671. }
  672. );
  673. } else {
  674. formData.data.countryId = "";
  675. formData.data.provinceId = "";
  676. formData.data.cityId = "";
  677. formData.data.buyPostalCode = "";
  678. formData.data.buyAddress = "";
  679. }
  680. };
  681. const createFilter = (queryString) => {
  682. return (restaurant) => {
  683. return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
  684. };
  685. };
  686. const querySearchPerson = (queryString, callback) => {
  687. const results = queryString ? customerUserList.value.filter(createFilter(queryString)) : customerUserList.value;
  688. callback(results);
  689. };
  690. const handlePerson = (item) => {
  691. formData.data.customerTel = item.phone;
  692. };
  693. const selectProduct = (goods) => {
  694. if (goods && goods.id) {
  695. let data = formData.data.quotationProductList.filter((item) => item.productId === goods.id);
  696. if (data && data.length > 0) {
  697. return ElMessage("该产品已添加");
  698. }
  699. let fileUrl = "";
  700. if (goods.fileList && goods.fileList.length > 0) {
  701. fileUrl = goods.fileList[0].fileUrl;
  702. }
  703. let packMethod = "";
  704. if (goods.innerPackMethod) {
  705. let innerPackMethod = goods.innerPackMethod.split(",");
  706. innerPackMethod.map((item) => {
  707. if (packMethod) {
  708. packMethod = packMethod + "," + proxy.dictValueLabel(item, innerMethod.value);
  709. } else {
  710. packMethod = proxy.dictValueLabel(item, innerMethod.value);
  711. }
  712. });
  713. }
  714. if (goods.outerPackMethod) {
  715. let outerPackMethod = goods.outerPackMethod.split(",");
  716. outerPackMethod.map((item) => {
  717. if (packMethod) {
  718. packMethod = packMethod + "," + proxy.dictValueLabel(item, outsideMethod.value);
  719. } else {
  720. packMethod = proxy.dictValueLabel(item, outsideMethod.value);
  721. }
  722. });
  723. }
  724. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  725. formData.data.quotationProductList.push({
  726. fileUrl: fileUrl,
  727. productId: goods.id,
  728. productName: goods.name,
  729. productModel: goods.productLong + "*" + goods.productWide + "*" + goods.productHigh,
  730. quantity: undefined,
  731. price: undefined,
  732. amount: "",
  733. tradeMethods: "",
  734. packMethod: packMethod,
  735. });
  736. } else {
  737. formData.data.quotationProductList = [
  738. {
  739. fileUrl: fileUrl,
  740. productId: goods.id,
  741. productName: goods.name,
  742. productModel: goods.productLong + "*" + goods.productWide + "*" + goods.productHigh,
  743. quantity: undefined,
  744. price: undefined,
  745. amount: "",
  746. tradeMethods: "",
  747. packMethod: packMethod,
  748. },
  749. ];
  750. }
  751. ElMessage({
  752. message: "添加成功!",
  753. type: "success",
  754. });
  755. } else {
  756. return ElMessage("选择错误");
  757. }
  758. };
  759. const onPicture = (path) => {
  760. window.open(path, "_blank");
  761. };
  762. const handleRemove = async (index) => {
  763. await formData.data.quotationProductList.splice(index, 1);
  764. totalAmount();
  765. };
  766. const calculationAmount = () => {
  767. nextTick(() => {
  768. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  769. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  770. let money = 0;
  771. if (formData.data.quotationProductList[i].quantity && formData.data.quotationProductList[i].price) {
  772. money = parseFloat(Number(formData.data.quotationProductList[i].quantity) * Number(formData.data.quotationProductList[i].price)).toFixed(2);
  773. }
  774. formData.data.quotationProductList[i].amount = money;
  775. }
  776. }
  777. nextTick(() => {
  778. totalAmount();
  779. });
  780. });
  781. };
  782. const totalAmount = () => {
  783. let money = 0;
  784. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  785. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  786. if (formData.data.quotationProductList[i].amount) {
  787. money = parseFloat(Number(money) + Number(formData.data.quotationProductList[i].amount)).toFixed(2);
  788. }
  789. }
  790. }
  791. if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
  792. for (let i = 0; i < formData.data.quotationPayList.length; i++) {
  793. if (formData.data.quotationPayList[i].amount) {
  794. money = parseFloat(Number(money) + Number(formData.data.quotationPayList[i].amount)).toFixed(2);
  795. }
  796. }
  797. }
  798. formData.data.amount = money;
  799. };
  800. const clickAdd = () => {
  801. if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
  802. formData.data.quotationPayList.push({
  803. payName: "",
  804. amount: undefined,
  805. remark: "",
  806. });
  807. } else {
  808. formData.data.quotationPayList = [{ payName: "", amount: undefined, remark: "" }];
  809. }
  810. };
  811. const handleDelete = async (index) => {
  812. await formData.data.quotationPayList.splice(index, 1);
  813. totalAmount();
  814. };
  815. const querySearch = (queryString, callback) => {
  816. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  817. if (res.rows && res.rows.length > 0) {
  818. res.rows = res.rows.map((item) => {
  819. return {
  820. ...item,
  821. value: item.payName,
  822. };
  823. });
  824. callback(res.rows);
  825. } else {
  826. callback([]);
  827. }
  828. });
  829. };
  830. const handleSubmit = async () => {
  831. let status = await submit.value.handleSubmit(() => {});
  832. if (status) {
  833. if (!(formData.data.quotationProductList && formData.data.quotationProductList.length > 0)) {
  834. ElMessage("请添加至少一件商品");
  835. return false;
  836. }
  837. return true;
  838. } else {
  839. setTimeout(() => {
  840. const errorDiv = document.getElementsByClassName("is-error");
  841. errorDiv[0].scrollIntoView();
  842. }, 0);
  843. }
  844. return status;
  845. };
  846. // 接收父组件的传值
  847. const props = defineProps({
  848. queryData: Object,
  849. });
  850. watch(
  851. props.queryData,
  852. () => {
  853. formOption.disabled = judgeStatus();
  854. if (props.queryData && (route.query.processType == 10 || route.query.processType == 20)) {
  855. for (var text in props.queryData) {
  856. formData.data[text] = props.queryData[text];
  857. }
  858. if (formData.data.countryId) {
  859. getCityData(formData.data.countryId, "20");
  860. }
  861. if (formData.data.provinceId) {
  862. getCityData(formData.data.provinceId, "30");
  863. }
  864. }
  865. },
  866. {
  867. deep: true,
  868. }
  869. );
  870. onMounted(() => {
  871. if (props.queryData.priceSheetId) {
  872. proxy.post("/saleQuotation/detail", { id: props.queryData.priceSheetId }).then((res) => {
  873. res.countryId = res.buyCountryId;
  874. res.provinceId = res.buyProvinceId;
  875. res.cityId = res.buyCityId;
  876. for (var text in res) {
  877. formData.data[text] = res[text];
  878. }
  879. if (formData.data.ehsdJson) {
  880. let ehsdJson = JSON.parse(formData.data.ehsdJson);
  881. if (ehsdJson.deliveryTime) {
  882. formData.data.deliveryTime = ehsdJson.deliveryTime;
  883. }
  884. }
  885. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  886. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  887. if (formData.data.quotationProductList[i].ehsdJson) {
  888. let ehsdJsonProduct = JSON.parse(formData.data.quotationProductList[i].ehsdJson);
  889. if (ehsdJsonProduct.packMethod) {
  890. formData.data.quotationProductList[i].packMethod = ehsdJsonProduct.packMethod;
  891. }
  892. if (ehsdJsonProduct.tradeMethods) {
  893. formData.data.quotationProductList[i].tradeMethods = ehsdJsonProduct.tradeMethods;
  894. }
  895. }
  896. }
  897. let fileIds = formData.data.quotationProductList.map((item) => item.productId);
  898. proxy.post("/fileInfo/getList", { businessIdList: fileIds }).then((resFile) => {
  899. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  900. if (resFile[formData.data.quotationProductList[i].productId] && resFile[formData.data.quotationProductList[i].productId].length > 0) {
  901. formData.data.quotationProductList[i].fileUrl = resFile[formData.data.quotationProductList[i].productId][0].fileUrl;
  902. }
  903. }
  904. });
  905. }
  906. delete formData.data.id;
  907. delete formData.data.code;
  908. getCityData(formData.data.countryId, "20");
  909. if (formData.data.provinceId) {
  910. getCityData(formData.data.provinceId, "30");
  911. }
  912. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  913. formData.data.quotationProductList = formData.data.quotationProductList.map((item) => {
  914. delete item.id;
  915. return {
  916. ...item,
  917. };
  918. });
  919. }
  920. if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
  921. formData.data.quotationPayList = formData.data.quotationPayList.map((item) => {
  922. delete item.id;
  923. return {
  924. ...item,
  925. };
  926. });
  927. }
  928. });
  929. }
  930. });
  931. const clickCustomerProduct = () => {
  932. if (!formData.data.buyCorporationId) {
  933. return ElMessage("请先选择客户");
  934. }
  935. openProductCustomer.value = true;
  936. };
  937. const getFormData = () => {
  938. return formData.data;
  939. };
  940. // 向父组件暴露
  941. defineExpose({
  942. getFormData,
  943. handleSubmit,
  944. });
  945. </script>
  946. <style lang="scss" scoped>
  947. ::v-deep(.el-input-number .el-input__inner) {
  948. text-align: left;
  949. }
  950. .pic {
  951. object-fit: contain;
  952. width: 50px;
  953. height: 50px;
  954. cursor: pointer;
  955. vertical-align: middle;
  956. }
  957. .shrinkPadding {
  958. padding-right: 0 !important;
  959. }
  960. </style>