PriceSheet.vue 34 KB

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