PriceSheet.vue 35 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 allow-create @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. label: "合同模板",
  394. },
  395. {
  396. type: "select",
  397. label: "选择合同模板",
  398. prop: "contractTemplateId",
  399. data: templateList.value,
  400. fn: (val) => {
  401. changeTemplate(val);
  402. },
  403. },
  404. {
  405. type: "slot",
  406. slotName: "seller",
  407. label: "卖方信息",
  408. itemWidth: 50,
  409. },
  410. {
  411. type: "slot",
  412. slotName: "buyer",
  413. label: "买方信息",
  414. itemWidth: 50,
  415. },
  416. {
  417. type: "slot",
  418. slotName: "payment",
  419. label: "付款信息",
  420. },
  421. {
  422. type: "slot",
  423. slotName: "delivery",
  424. label: "交付信息",
  425. },
  426. {
  427. type: "slot",
  428. slotName: "commodity",
  429. label: "商品信息",
  430. },
  431. {
  432. type: "slot",
  433. slotName: "otherCharge",
  434. label: "其他收费项目",
  435. },
  436. {
  437. type: "slot",
  438. slotName: "offerMoney",
  439. },
  440. ];
  441. });
  442. const rules = ref({
  443. contractTemplateId: [{ required: true, message: "请选择合同模板", trigger: "change" }],
  444. buyCorporationId: [{ required: true, message: "请选择公司", trigger: "change" }],
  445. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  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: "请输入尺寸 cm*cm*cm", trigger: "blur" }],
  450. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  451. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  452. packMethod: [{ required: true, message: "请输入包装方式", trigger: "blur" }],
  453. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  454. payName: [{ required: true, message: "请输入收费项目", trigger: ["change", "blur"] }],
  455. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  456. effective: [{ required: true, message: "请输入报价有效期", trigger: "blur" }],
  457. deliveryTime: [{ required: true, message: "请选择交货期限", trigger: "change" }],
  458. paymentMethod: [{ required: true, message: "请选择付款方式", trigger: "change" }],
  459. advanceRatio: [{ required: true, message: "请输入预付比例", trigger: "blur" }],
  460. tradeMethods: [{ required: true, message: "请选择贸易方式", trigger: "change" }],
  461. transportMethod: [{ required: true, message: "请选择运输方式", trigger: "change" }],
  462. transportRemark: [{ required: true, message: "请输入运输说明", trigger: "blur" }],
  463. remark: [{ required: true, message: "请输入付款条件", trigger: "blur" }],
  464. });
  465. const getDict = () => {
  466. proxy
  467. .getDictOne([
  468. "inner_packaging_method_ehsd",
  469. "outside_packaging_method_ehsd",
  470. "account_currency",
  471. "funds_payment_method",
  472. "trade_methods",
  473. "shipping_method",
  474. ])
  475. .then((res) => {
  476. innerMethod.value = res["inner_packaging_method_ehsd"].map((x) => ({
  477. label: x.dictValue,
  478. value: x.dictKey,
  479. }));
  480. outsideMethod.value = res["outside_packaging_method_ehsd"].map((x) => ({
  481. label: x.dictValue,
  482. value: x.dictKey,
  483. }));
  484. accountCurrency.value = res["account_currency"].map((x) => ({
  485. label: x.dictValue,
  486. value: x.dictKey,
  487. }));
  488. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  489. label: x.dictValue,
  490. value: x.dictKey,
  491. }));
  492. tradeMethods.value = res["trade_methods"].map((x) => ({
  493. label: x.dictValue,
  494. value: x.dictKey,
  495. }));
  496. shippingMethod.value = res["shipping_method"].map((x) => ({
  497. label: x.dictValue,
  498. value: x.dictKey,
  499. }));
  500. });
  501. proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  502. templateList.value = res.rows.map((item) => {
  503. return {
  504. ...item,
  505. label: item.templateName,
  506. value: item.id,
  507. };
  508. });
  509. });
  510. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  511. corporationList.value = res.rows.map((item) => {
  512. return {
  513. ...item,
  514. label: item.name,
  515. value: item.id,
  516. };
  517. });
  518. });
  519. proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  520. customerList.value = res.rows.map((item) => {
  521. return {
  522. ...item,
  523. label: item.name,
  524. value: item.id,
  525. };
  526. });
  527. });
  528. };
  529. getDict();
  530. const changeTemplate = (val) => {
  531. if (val) {
  532. proxy.post("/contractTemplate/detail", { id: val }).then(
  533. (res) => {
  534. proxy.post("/customizeArea/list", { parentId: "0" }).then((resCountry) => {
  535. let sellCountryData = resCountry.filter((item) => item.id === res.countryId);
  536. if (sellCountryData && sellCountryData.length > 0) {
  537. formData.data.sellCountryName = sellCountryData[0].chineseName;
  538. } else {
  539. formData.data.sellCountryName = "";
  540. }
  541. });
  542. if (res.countryId) {
  543. proxy.post("/customizeArea/list", { parentId: res.countryId }).then((resProvince) => {
  544. let sellProvinceData = resProvince.filter((item) => item.id === res.provinceId);
  545. if (sellProvinceData && sellProvinceData.length > 0) {
  546. formData.data.sellProvinceName = sellProvinceData[0].name;
  547. } else {
  548. formData.data.sellProvinceName = "";
  549. }
  550. });
  551. } else {
  552. formData.data.sellProvinceName = "";
  553. }
  554. if (res.provinceId) {
  555. proxy.post("/customizeArea/list", { parentId: res.provinceId }).then((resCity) => {
  556. let sellCityData = resCity.filter((item) => item.id === res.cityId);
  557. if (sellCityData && sellCityData.length > 0) {
  558. formData.data.sellCityName = sellCityData[0].name;
  559. } else {
  560. formData.data.sellCityName = "";
  561. }
  562. });
  563. } else {
  564. formData.data.sellCityName = "";
  565. }
  566. formData.data.sellCorporationId = res.corporationId;
  567. formData.data.sellContactName = res.contactName;
  568. formData.data.sellContactNumber = res.contactNumber;
  569. formData.data.sellAddress = res.address;
  570. },
  571. (err) => {
  572. console.log(err);
  573. formData.data.sellCorporationId = "";
  574. formData.data.sellContactName = "";
  575. formData.data.sellContactNumber = "";
  576. formData.data.sellCountryName = "";
  577. formData.data.sellProvinceName = "";
  578. formData.data.sellCityName = "";
  579. formData.data.sellAddress = "";
  580. }
  581. );
  582. } else {
  583. formData.data.sellCorporationId = "";
  584. formData.data.sellContactName = "";
  585. formData.data.sellContactNumber = "";
  586. formData.data.sellCountryName = "";
  587. formData.data.sellProvinceName = "";
  588. formData.data.sellCityName = "";
  589. formData.data.sellAddress = "";
  590. }
  591. };
  592. const getCityData = (id, type, isChange) => {
  593. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  594. if (type === "20") {
  595. provinceData.value = res;
  596. if (isChange) {
  597. formData.data.provinceId = "";
  598. formData.data.provinceName = "";
  599. formData.data.cityId = "";
  600. formData.data.cityName = "";
  601. }
  602. } else if (type === "30") {
  603. cityData.value = res;
  604. if (isChange) {
  605. formData.data.cityId = "";
  606. formData.data.cityName = "";
  607. }
  608. } else {
  609. countryData.value = res;
  610. }
  611. });
  612. };
  613. getCityData("0");
  614. const changeCustomer = (val) => {
  615. formData.data.quotationProductList = [];
  616. formData.data.customerName = "";
  617. formData.data.customerTel = "";
  618. if (val) {
  619. proxy.post("/customer/detail", { id: val }).then(
  620. (res) => {
  621. if (res.customerUserList && res.customerUserList.length > 0) {
  622. formData.data.buyContactName = res.customerUserList[0].name;
  623. if (res.customerUserList[0].contactJson) {
  624. let contactJson = JSON.parse(res.customerUserList[0].contactJson);
  625. if (contactJson && contactJson.length > 0) {
  626. formData.data.buyContactNumber = contactJson[0].contactNo;
  627. }
  628. }
  629. customerUserList.value = res.customerUserList.map((item) => {
  630. return {
  631. ...item,
  632. value: item.name,
  633. };
  634. });
  635. }
  636. formData.data.countryId = res.countryId;
  637. formData.data.provinceId = res.provinceId;
  638. formData.data.cityId = res.cityId;
  639. formData.data.buyPostalCode = res.zipCode;
  640. formData.data.buyAddress = res.address;
  641. getCityData(formData.data.countryId, "20");
  642. getCityData(formData.data.provinceId, "30");
  643. },
  644. (err) => {
  645. console.log(err);
  646. formData.data.countryId = "";
  647. formData.data.provinceId = "";
  648. formData.data.cityId = "";
  649. formData.data.buyPostalCode = "";
  650. formData.data.buyAddress = "";
  651. }
  652. );
  653. } else {
  654. formData.data.countryId = "";
  655. formData.data.provinceId = "";
  656. formData.data.cityId = "";
  657. formData.data.buyPostalCode = "";
  658. formData.data.buyAddress = "";
  659. }
  660. };
  661. const createFilter = (queryString) => {
  662. return (restaurant) => {
  663. return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
  664. };
  665. };
  666. const querySearchPerson = (queryString, callback) => {
  667. const results = queryString ? customerUserList.value.filter(createFilter(queryString)) : customerUserList.value;
  668. callback(results);
  669. };
  670. const handlePerson = (item) => {
  671. formData.data.customerTel = item.phone;
  672. };
  673. const selectProduct = (goods) => {
  674. if (goods && goods.id) {
  675. let data = formData.data.quotationProductList.filter((item) => item.productId === goods.id);
  676. if (data && data.length > 0) {
  677. return ElMessage("该产品已添加");
  678. }
  679. let fileUrl = "";
  680. if (goods.fileList && goods.fileList.length > 0) {
  681. fileUrl = goods.fileList[0].fileUrl;
  682. }
  683. let packMethod = "";
  684. if (goods.innerPackMethod) {
  685. let innerPackMethod = goods.innerPackMethod.split(",");
  686. innerPackMethod.map((item) => {
  687. if (packMethod) {
  688. packMethod = packMethod + "," + proxy.dictValueLabel(item, innerMethod.value);
  689. } else {
  690. packMethod = proxy.dictValueLabel(item, innerMethod.value);
  691. }
  692. });
  693. }
  694. if (goods.outerPackMethod) {
  695. let outerPackMethod = goods.outerPackMethod.split(",");
  696. outerPackMethod.map((item) => {
  697. if (packMethod) {
  698. packMethod = packMethod + "," + proxy.dictValueLabel(item, outsideMethod.value);
  699. } else {
  700. packMethod = proxy.dictValueLabel(item, outsideMethod.value);
  701. }
  702. });
  703. }
  704. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  705. formData.data.quotationProductList.push({
  706. fileUrl: fileUrl,
  707. productId: goods.id,
  708. productName: goods.name,
  709. productModel: goods.productLong + "*" + goods.productWide + "*" + goods.productHigh,
  710. quantity: undefined,
  711. price: undefined,
  712. amount: "",
  713. tradeMethods: "",
  714. packMethod: packMethod,
  715. });
  716. } else {
  717. formData.data.quotationProductList = [
  718. {
  719. fileUrl: fileUrl,
  720. productId: goods.id,
  721. productName: goods.name,
  722. productModel: goods.productLong + "*" + goods.productWide + "*" + goods.productHigh,
  723. quantity: undefined,
  724. price: undefined,
  725. amount: "",
  726. tradeMethods: "",
  727. packMethod: packMethod,
  728. },
  729. ];
  730. }
  731. ElMessage({
  732. message: "添加成功!",
  733. type: "success",
  734. });
  735. } else {
  736. return ElMessage("选择错误");
  737. }
  738. };
  739. const onPicture = (path) => {
  740. window.open(path, "_blank");
  741. };
  742. const handleRemove = async (index) => {
  743. await formData.data.quotationProductList.splice(index, 1);
  744. totalAmount();
  745. };
  746. const calculationAmount = () => {
  747. nextTick(() => {
  748. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  749. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  750. let money = 0;
  751. if (formData.data.quotationProductList[i].quantity && formData.data.quotationProductList[i].price) {
  752. money = parseFloat(Number(formData.data.quotationProductList[i].quantity) * Number(formData.data.quotationProductList[i].price)).toFixed(2);
  753. }
  754. formData.data.quotationProductList[i].amount = money;
  755. }
  756. }
  757. nextTick(() => {
  758. totalAmount();
  759. });
  760. });
  761. };
  762. const totalAmount = () => {
  763. let money = 0;
  764. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  765. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  766. if (formData.data.quotationProductList[i].amount) {
  767. money = parseFloat(Number(money) + Number(formData.data.quotationProductList[i].amount)).toFixed(2);
  768. }
  769. }
  770. }
  771. if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
  772. for (let i = 0; i < formData.data.quotationPayList.length; i++) {
  773. if (formData.data.quotationPayList[i].amount) {
  774. money = parseFloat(Number(money) + Number(formData.data.quotationPayList[i].amount)).toFixed(2);
  775. }
  776. }
  777. }
  778. formData.data.amount = money;
  779. };
  780. const clickAdd = () => {
  781. if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
  782. formData.data.quotationPayList.push({
  783. payName: "",
  784. amount: undefined,
  785. remark: "",
  786. });
  787. } else {
  788. formData.data.quotationPayList = [{ payName: "", amount: undefined, remark: "" }];
  789. }
  790. };
  791. const handleDelete = async (index) => {
  792. await formData.data.quotationPayList.splice(index, 1);
  793. totalAmount();
  794. };
  795. const querySearch = (queryString, callback) => {
  796. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  797. if (res.rows && res.rows.length > 0) {
  798. res.rows = res.rows.map((item) => {
  799. return {
  800. ...item,
  801. value: item.payName,
  802. };
  803. });
  804. callback(res.rows);
  805. } else {
  806. callback([]);
  807. }
  808. });
  809. };
  810. const handleSubmit = async () => {
  811. let status = await submit.value.handleSubmit(() => {});
  812. if (status) {
  813. if (!(formData.data.quotationProductList && formData.data.quotationProductList.length > 0)) {
  814. ElMessage("请添加至少一件商品");
  815. return false;
  816. }
  817. return true;
  818. } else {
  819. setTimeout(() => {
  820. const errorDiv = document.getElementsByClassName("is-error");
  821. errorDiv[0].scrollIntoView();
  822. }, 0);
  823. }
  824. return status;
  825. };
  826. // 接收父组件的传值
  827. const props = defineProps({
  828. queryData: Object,
  829. });
  830. onMounted(() => {
  831. if (props.queryData.priceSheetId) {
  832. proxy.post("/saleQuotation/detail", { id: props.queryData.priceSheetId }).then((res) => {
  833. for (var text in res) {
  834. formData.data[text] = res[text];
  835. }
  836. if (formData.data.ehsdJson) {
  837. let ehsdJson = JSON.parse(formData.data.ehsdJson);
  838. if (ehsdJson.deliveryTime) {
  839. formData.data.deliveryTime = ehsdJson.deliveryTime;
  840. }
  841. }
  842. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  843. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  844. if (formData.data.quotationProductList[i].ehsdJson) {
  845. let ehsdJsonProduct = JSON.parse(formData.data.quotationProductList[i].ehsdJson);
  846. if (ehsdJsonProduct.packMethod) {
  847. formData.data.quotationProductList[i].packMethod = ehsdJsonProduct.packMethod;
  848. }
  849. if (ehsdJsonProduct.tradeMethods) {
  850. formData.data.quotationProductList[i].tradeMethods = ehsdJsonProduct.tradeMethods;
  851. }
  852. }
  853. }
  854. let fileIds = formData.data.quotationProductList.map((item) => item.productId);
  855. proxy.post("/fileInfo/getList", { businessIdList: fileIds }).then((resFile) => {
  856. for (let i = 0; i < formData.data.quotationProductList.length; i++) {
  857. if (resFile[formData.data.quotationProductList[i].productId] && resFile[formData.data.quotationProductList[i].productId].length > 0) {
  858. formData.data.quotationProductList[i].fileUrl = resFile[formData.data.quotationProductList[i].productId][0].fileUrl;
  859. }
  860. }
  861. });
  862. }
  863. delete formData.data.id;
  864. delete formData.data.code;
  865. getCityData(formData.data.countryId, "20");
  866. getCityData(formData.data.provinceId, "30");
  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>