PriceSheet.vue 31 KB

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