PriceSheet.vue 36 KB

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