PriceSheet.vue 37 KB

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