Purchase.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom">
  4. <template #btn>
  5. <div>
  6. <el-button type="primary" v-if="
  7. [30].includes(route.query.processType) || !route.query.processType
  8. " @click="clickCopy(1)">复制合同</el-button>
  9. </div>
  10. </template>
  11. <template #seller>
  12. <div style="width: 100%">
  13. <el-form-item prop="buyCorporationId" label="买方信息" class="wid100">
  14. <el-select v-model="formData.data.buyCorporationId" placeholder="请选择买方公司" style="width: 100%" @change="buyCorporationIdChange" filterable>
  15. <el-option v-for="item in corporationList" :key="item.value" :label="item.label" :value="item.value" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="地址" class="wid100">
  19. <el-row style="width:100%">
  20. <el-col :span="8">
  21. <el-form-item label="" prop="buyCountryName" label-width="0px" class="margin-b-0 wid100">
  22. <el-input v-model="formData.data.buyCountryName" placeholder="请输入国家" />
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="8">
  26. <el-form-item label="" prop="buyProvinceName" label-width="0px" class="margin-b-0 wid100">
  27. <el-input v-model="formData.data.buyProvinceName" placeholder="请输入省/州" />
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="8">
  31. <el-form-item label="" prop="buyCityName" label-width="0px" class="margin-b-0 wid100">
  32. <el-input v-model="formData.data.buyCityName" placeholder="请输入城市" />
  33. </el-form-item>
  34. </el-col>
  35. </el-row>
  36. </el-form-item>
  37. <el-form-item label="详细地址" prop="buyAddress" class="wid100">
  38. <el-input v-model="formData.data.buyAddress" type="textarea">
  39. </el-input>
  40. </el-form-item>
  41. <el-form-item label="联系人" class="wid100">
  42. <el-row style="width:100%">
  43. <el-col :span="8">
  44. <el-form-item label="" prop="buyContactName" label-width="0px" class="margin-b-0 wid100">
  45. <el-input v-model="formData.data.buyContactName" placeholder="请输入联系人" />
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="16">
  49. <el-form-item label="" prop="buyContactNumber" label-width="0px" class="margin-b-0 wid100">
  50. <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
  51. </el-form-item>
  52. </el-col>
  53. </el-row>
  54. </el-form-item>
  55. </div>
  56. </template>
  57. <template #buyer>
  58. <div style="width: 100%">
  59. <el-form-item label="卖方信息" prop="sellCorporationId" class="wid100">
  60. <el-select v-model="formData.data.sellCorporationId" filterable remote reserve-keyword placeholder="请输入关键字" remote-show-suffix
  61. :remote-method="remoteMethod" :loading="loadingSearch" @input="remoteMethod" style="width: 100%" @change="changeSupplier" v-if="
  62. [30].includes(route.query.processType) ||
  63. !route.query.processType
  64. ">
  65. <el-option v-for="item in supplierList" :key="item.value" :label="item.label" :value="item.value" />
  66. </el-select>
  67. <el-select v-model="formData.data.sellCorporationName" disabled v-else style="width: 100%">
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="地址" class="wid100" required>
  71. <el-row style="width: 100%">
  72. <el-col :span="6">
  73. <el-form-item label="" prop="countryId" class="margin-b-0">
  74. <el-select v-model="formData.data.countryId" placeholder="国家" filterable @change="(val) => getCityData(val, '20', true)">
  75. <el-option v-for="item in countryData" :label="item.name" :value="item.id">
  76. </el-option>
  77. </el-select>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="6">
  81. <el-form-item label="" prop="provinceName" class="margin-b-0">
  82. <selectCity placeholder="省/洲" @change="(val) => getCityData(val, '30', true)" addressId="provinceId" addressName="provinceName"
  83. v-model="formData.data" :data="provinceData">
  84. </selectCity>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="6">
  88. <el-form-item label="" prop="cityName" class="margin-b-0">
  89. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData">
  90. </selectCity>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="6">
  94. <el-form-item label="" prop="sellPostalCode" class="margin-b-0">
  95. <el-input v-model="formData.data.sellPostalCode" placeholder="请输入邮编" />
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. </el-form-item>
  100. <el-form-item label="详细地址" prop="sellAddress" class="wid100">
  101. <el-input v-model="formData.data.sellAddress" type="textarea">
  102. </el-input>
  103. </el-form-item>
  104. <el-form-item label="联系人" class="wid100" required>
  105. <el-row style="width: 100%">
  106. <el-col :span="8">
  107. <el-form-item label="" prop="sellContactName" label-width="0px" class="margin-b-0 wid100">
  108. <el-input v-model="formData.data.sellContactName" clearable placeholder="请输入联系人">
  109. </el-input>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="16">
  113. <el-form-item label="" prop="sellContactNumber" label-width="0px" class="margin-b-0 wid100">
  114. <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. </el-form-item>
  119. </div>
  120. </template>
  121. <template #commodity>
  122. <div style="width: 100%">
  123. <el-table :data="formData.data.purchaseProductList" style="width: 100%; ">
  124. <el-table-column label="商品图片" width="80">
  125. <template #default="{ row }">
  126. <div v-if="row.fileUrl">
  127. <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  128. </div>
  129. <div v-else></div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column prop="productName" label="商品名称" min-width="130" />
  133. <el-table-column prop="productCode" label="商品编码" width="130" />
  134. <el-table-column label="尺寸 cm*cm*cm" width="180">
  135. <template #default="{ row, $index }">
  136. <div style="width: 100%">
  137. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  138. </div>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="数量" prop="subscribeCount" width="100" v-if="route.query.ids" />
  142. <el-table-column label="已采购数量" prop="purchaseCount" width="100" v-if="route.query.ids" />
  143. <el-table-column label="采购数量" width="150">
  144. <template #default="{ row, $index }">
  145. <div style="width: 100%">
  146. <el-form-item :prop="'purchaseProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true"
  147. class="margin-b-0 wid100">
  148. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  149. :controls="false" :min="0" @change="calculationAmount('quantity')" />
  150. </el-form-item>
  151. </div>
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="单价" width="180">
  155. <template #default="{ row, $index }">
  156. <div style="width: 100%">
  157. <el-form-item :prop="'purchaseProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true"
  158. class="margin-b-0 wid100">
  159. <div style="display:flex;">
  160. <el-input-number onmousewheel="return false;" v-model="row.price" placeholder="请输入" style="width: 100%" :precision="2"
  161. :controls="false" :min="0" @change="calculationAmount()" />
  162. <el-popover placement="top-start" :width="400" trigger="hover" @show="showEcharts(row,$index)">
  163. <template #default>
  164. <div>
  165. <div>
  166. <img src="@/assets/images/money1.png" alt="" class="img" />
  167. <span style="font-size:14px;font-weight:700;color:#000"> 该供应商近期采购单价:</span>
  168. <div style="padding:5px 0px 0px 20px">
  169. <div v-for="(item,index) in row.supplyPurchaseProductPriceList" :key="index">
  170. <span>{{item.createTime.slice(0,10)}} </span>
  171. <span style="margin-left:40px">CNY {{moneyFormat(item.price,2)}} </span>
  172. </div>
  173. </div>
  174. </div>
  175. <div style="margin-top:15px">
  176. <img src="@/assets/images/money2.png" alt="" class="img" />
  177. <span style="font-size:14px;font-weight:700;color:#000"> 供货推荐:</span>
  178. <div style="padding:5px 0px 0px 20px">
  179. <div v-for="(item,index) in row.topPriceList " :key="index">
  180. <span>{{item.supplierName}} </span>
  181. <span style="margin-left:40px"> CNY {{moneyFormat(item.price,2)}} </span>
  182. </div>
  183. </div>
  184. </div>
  185. <div style="margin-top:15px">
  186. <img src="@/assets/images/money3.png" alt="" class="img" />
  187. <span style="font-size:14px;font-weight:700;color:#000"> 近期采购单价:</span>
  188. <div style="padding:5px 0px 0px 20px">
  189. <div v-for="(item,index) in row.purchaseProductPriceList " :key="index">
  190. <span>{{item.createTime.slice(0,10)}} </span>
  191. <span style="margin-left:40px"> CNY {{moneyFormat(item.price,2)}} </span>
  192. </div>
  193. </div>
  194. </div>
  195. <div :ref="row.productId+$index" :id="row.productId+$index" style="height:180px">
  196. </div>
  197. </div>
  198. </template>
  199. <template #reference>
  200. <div style="margin-left:10px;cursor:pointer;position:relative;top:4px">
  201. <el-icon :size="20" color="#85c1a6">
  202. <WarningFilled />
  203. </el-icon>
  204. </div>
  205. </template>
  206. </el-popover>
  207. </div>
  208. </el-form-item>
  209. </div>
  210. </template>
  211. </el-table-column>
  212. <el-table-column prop="amount" label="小计" width="120" />
  213. <el-table-column label="操作" width="120" align="center" fixed="right" v-if="!judgeStatus()">
  214. <template #default="{ $index }">
  215. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  216. </template>
  217. </el-table-column>
  218. </el-table>
  219. </div>
  220. </template>
  221. <template #otherCharge>
  222. <div style="width: 100%">
  223. <el-button type="primary" @click="clickAdd()" plain style="margin-bottom: 16px" v-if="!judgeStatus()">添加行</el-button>
  224. <el-table :data="formData.data.purchaseProjectList" style="width: 100%;">
  225. <el-table-column label="收费项目" width="220">
  226. <template #default="{ row, $index }">
  227. <div style="width: 100%">
  228. <el-form-item :prop="'purchaseProjectList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true"
  229. class="margin-b-0 wid100">
  230. <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50"
  231. placeholder="请输入收费项目" />
  232. </el-form-item>
  233. </div>
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="备注">
  237. <template #default="{ row, $index }">
  238. <div style="width: 100%">
  239. <el-form-item :prop="'purchaseProjectList.' + $index + '.remark'" class="margin-b-0 wid100">
  240. <el-input v-model="row.remark" placeholder="请输入备注" />
  241. </el-form-item>
  242. </div>
  243. </template>
  244. </el-table-column>
  245. <el-table-column :label="'金额'" width="130">
  246. <template #default="{ row, $index }">
  247. <div style="width: 100%">
  248. <el-form-item :prop="'purchaseProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true"
  249. class="margin-b-0 wid100">
  250. <el-input-number onmousewheel="return false;" v-model="row.amount" placeholder="请输入金额" style="width: 100%" :precision="2"
  251. :controls="false" :min="0" @change="totalAmount()" />
  252. </el-form-item>
  253. </div>
  254. </template>
  255. </el-table-column>
  256. <el-table-column label="操作" width="60" align="center" fixed="right" v-if="!judgeStatus()">
  257. <template #default="{ $index }">
  258. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  259. </template>
  260. </el-table-column>
  261. </el-table>
  262. </div>
  263. </template>
  264. <template #contractClause>
  265. <div style="width: 100%">
  266. <el-row style=" width: 100%">
  267. <el-col :span="8">
  268. <el-form-item label="合同模板" prop="contractTemplateId" class="wid100">
  269. <el-select v-model="formData.data.contractTemplateId" style="width: 100%" @change="changeContractTemplate">
  270. <el-option v-for="item in templateList" :key="item.value" :label="item.label" :value="item.value" />
  271. </el-select>
  272. </el-form-item>
  273. </el-col>
  274. </el-row>
  275. <div style=" width: 100%">
  276. <el-form-item label="条款内容" prop="remark" class="margin-b-0 wid100">
  277. <Editor style="width: 100%" :value="formData.data.remark" @updateValue="updateContent" :readOnly="judgeStatus()" ref="remarkEditor" />
  278. </el-form-item>
  279. </div>
  280. </div>
  281. </template>
  282. </byForm>
  283. </div>
  284. </template>
  285. <script setup>
  286. import byForm from "@/components/byForm/index";
  287. import selectCity from "@/components/selectCity/index.vue";
  288. import { useRoute } from "vue-router";
  289. import Editor from "@/components/Editor/index.vue";
  290. import * as echarts from "echarts";
  291. import $bus from "@/bus/index.js";
  292. const route = useRoute();
  293. const { proxy } = getCurrentInstance();
  294. // 接收父组件的传值
  295. const props = defineProps({
  296. queryData: Object,
  297. });
  298. const invoiceType = computed(
  299. () => proxy.useUserStore().allDict["invoice_type"]
  300. );
  301. const fundsPaymentMethod = computed(
  302. () => proxy.useUserStore().allDict["funds_payment_method"]
  303. );
  304. const shippingMethod = computed(
  305. () => proxy.useUserStore().allDict["shipping_method"]
  306. );
  307. // const companyId = computed(() => proxy.useUserStore().user.companyId);
  308. const deliveryType = ref([
  309. {
  310. label: "买方地址",
  311. value: "1",
  312. },
  313. {
  314. label: "工厂交付",
  315. value: "2",
  316. },
  317. {
  318. label: "其他",
  319. value: "3",
  320. },
  321. ]);
  322. const supplierList = ref([]);
  323. const corporationList = ref([]);
  324. const templateList = ref([]);
  325. const customerUserList = ref([]);
  326. const countryData = ref([]);
  327. const provinceData = ref([]);
  328. const cityData = ref([]);
  329. const openProductCompany = ref(false);
  330. const copyType = ref(1);
  331. const copyContract = ref(false);
  332. const formData = reactive({
  333. data: {
  334. purchaseProductList: [],
  335. remark: "",
  336. },
  337. });
  338. const uploadData = ref({});
  339. const formDom = ref(null);
  340. const judgeStatus = () => {
  341. if (route.query.processType == 20 || route.query.processType == 10) {
  342. return true;
  343. }
  344. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  345. let data = props.queryData.recordList.filter(
  346. (item) => item.status === 2 && item.nodeType !== 1
  347. );
  348. if (data && data.length > 0) {
  349. return true;
  350. }
  351. }
  352. return false;
  353. };
  354. const formOption = reactive({
  355. inline: true,
  356. labelWidth: 100,
  357. itemWidth: 100,
  358. disabled: false,
  359. });
  360. const formConfig = computed(() => {
  361. return [
  362. // {
  363. // type: "slot",
  364. // slotName: "btn",
  365. // label: "",
  366. // itemWidth: 50,
  367. // },
  368. {
  369. type: "title",
  370. title: "贸易信息",
  371. haveLine: false,
  372. },
  373. {
  374. type: "slot",
  375. slotName: "seller",
  376. label: "",
  377. itemWidth: 50,
  378. },
  379. {
  380. type: "slot",
  381. slotName: "buyer",
  382. label: "",
  383. itemWidth: 50,
  384. },
  385. {
  386. type: "title",
  387. title: "付款信息",
  388. haveLine: true,
  389. },
  390. {
  391. type: "select",
  392. prop: "paymentMethod",
  393. label: "付款方式",
  394. data: fundsPaymentMethod.value,
  395. itemWidth: 25,
  396. },
  397. {
  398. type: "select",
  399. prop: "invoiceType",
  400. label: "发票类型",
  401. data: invoiceType.value,
  402. itemWidth: 25,
  403. },
  404. {
  405. type: "title",
  406. title: "交付信息",
  407. haveLine: true,
  408. },
  409. // {
  410. // type: "radio",
  411. // prop: "ss",
  412. // label: "交货类型",
  413. // border: true,
  414. // data: deliveryType.value,
  415. // itemWidth: 50,
  416. // },
  417. {
  418. type: "select",
  419. prop: "deliveryType",
  420. label: "交货类型",
  421. border: true,
  422. data: deliveryType.value,
  423. itemWidth: 50,
  424. fn: () => {
  425. changeAddress();
  426. },
  427. },
  428. {
  429. type: "input",
  430. prop: "address",
  431. itemType: "textarea",
  432. label: "详细地址",
  433. itemWidth: 50,
  434. },
  435. {
  436. type: "date",
  437. itemType: "date",
  438. prop: "deliveryTime",
  439. label: "交付日期",
  440. itemWidth: 50,
  441. },
  442. {
  443. type: "number",
  444. prop: "warranty",
  445. label: "质保期 (天)",
  446. precision: 0,
  447. min: 0,
  448. controls: false,
  449. itemWidth: 50,
  450. },
  451. // {
  452. // type: "select",
  453. // prop: "transportMethod",
  454. // label: "运输方式",
  455. // data: shippingMethod.value,
  456. // itemWidth: 50,
  457. // },
  458. // {
  459. // type: "slot",
  460. // slotName: "delivery",
  461. // label: "",
  462. // },
  463. {
  464. type: "title",
  465. title: "采购明细",
  466. haveLine: true,
  467. },
  468. {
  469. type: "slot",
  470. slotName: "commodity",
  471. label: "",
  472. },
  473. {
  474. type: "title",
  475. title: "其他收费项目",
  476. haveLine: true,
  477. },
  478. {
  479. type: "slot",
  480. slotName: "otherCharge",
  481. label: "",
  482. },
  483. {
  484. type: "title",
  485. title: "合同总金额",
  486. haveLine: true,
  487. },
  488. {
  489. type: "input",
  490. prop: "amount",
  491. label: "合同总金额",
  492. itemWidth: 25,
  493. disabled: true,
  494. },
  495. {
  496. type: "title",
  497. title: "合同条款",
  498. haveLine: true,
  499. },
  500. {
  501. type: "slot",
  502. slotName: "contractClause",
  503. label: "",
  504. },
  505. ];
  506. });
  507. const rules = ref({
  508. buyCorporationId: [
  509. { required: true, message: "请选择买方公司", trigger: "change" },
  510. ],
  511. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  512. buyContactName: [
  513. { required: true, message: "请输入联系人", trigger: ["change", "blur"] },
  514. ],
  515. buyContactNumber: [
  516. { required: true, message: "请输入联系电话", trigger: "blur" },
  517. ],
  518. sellCorporationId: [
  519. { required: true, message: "请选择卖方公司", trigger: "change" },
  520. ],
  521. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  522. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  523. sellContactName: [
  524. { required: true, message: "请输入联系人", trigger: ["change", "blur"] },
  525. ],
  526. sellContactNumber: [
  527. { required: true, message: "请输入联系电话", trigger: "blur" },
  528. ],
  529. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  530. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  531. invoiceType: [
  532. { required: true, message: "请选择发票类型", trigger: "change" },
  533. ],
  534. paymentMethod: [
  535. { required: true, message: "请选择付款方式", trigger: "change" },
  536. ],
  537. deliveryType: [
  538. { required: true, message: "请选择交货类型", trigger: "change" },
  539. ],
  540. address: [{ required: true, message: "请输入详细地址", trigger: ["blur"] }],
  541. deliveryTime: [
  542. { required: true, message: "请选择交付日期", trigger: "change" },
  543. ],
  544. warranty: [{ required: true, message: "请选择质保期 (天)", trigger: "blur" }],
  545. payName: [{ required: true, message: "请输入收费项目", trigger: ["blur"] }],
  546. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  547. remark: [{ required: true, message: "请输入条款内容", trigger: "blur" }],
  548. });
  549. const getDict = () => {
  550. proxy
  551. .post("/supplierInfo/page", {
  552. pageNum: 1,
  553. pageSize: 50,
  554. })
  555. .then((res) => {
  556. supplierList.value = res.rows.map((x) => ({
  557. ...x,
  558. label: x.name,
  559. value: x.id,
  560. }));
  561. });
  562. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  563. corporationList.value = res.rows.map((item) => {
  564. return {
  565. ...item,
  566. label: item.name,
  567. value: item.id,
  568. };
  569. });
  570. });
  571. proxy
  572. .post("/contractTemplate/page", { pageNum: 1, pageSize: 999 })
  573. .then((res) => {
  574. templateList.value = res.rows.map((item) => {
  575. return {
  576. ...item,
  577. label: item.templateName,
  578. value: item.id,
  579. };
  580. });
  581. });
  582. };
  583. const changeAddress = () => {
  584. if (formData.data.deliveryType === "1") {
  585. let buyCountryName = "";
  586. if (formData.data.buyCountryName) {
  587. buyCountryName = formData.data.buyCountryName;
  588. }
  589. let buyProvinceName = "";
  590. if (formData.data.buyProvinceName) {
  591. buyProvinceName = formData.data.buyProvinceName;
  592. }
  593. let buyCityName = "";
  594. if (formData.data.buyCityName) {
  595. buyCityName = formData.data.buyCityName;
  596. }
  597. let buyAddress = "";
  598. if (formData.data.buyAddress) {
  599. buyAddress = formData.data.buyAddress;
  600. }
  601. formData.data.address =
  602. buyCountryName +
  603. ", " +
  604. buyProvinceName +
  605. ", " +
  606. buyCityName +
  607. "," +
  608. buyAddress;
  609. } else if (formData.data.deliveryType === "2") {
  610. let countryName = "";
  611. if (formData.data.countryId) {
  612. let data = countryData.value.filter(
  613. (item) => item.id === formData.data.countryId
  614. );
  615. if (data && data.length > 0) countryName = data[0].chineseName;
  616. }
  617. let provinceName = "";
  618. if (formData.data.provinceId) {
  619. let data = provinceData.value.filter(
  620. (item) => item.id === formData.data.provinceId
  621. );
  622. if (data && data.length > 0) provinceName = data[0].name;
  623. } else {
  624. if (formData.data.provinceName) {
  625. provinceName = formData.data.provinceName;
  626. }
  627. }
  628. let cityName = "";
  629. if (formData.data.cityId) {
  630. let data = cityData.value.filter(
  631. (item) => item.id === formData.data.cityId
  632. );
  633. if (data && data.length > 0) cityName = data[0].name;
  634. } else {
  635. if (formData.data.cityName) {
  636. cityName = formData.data.cityName;
  637. }
  638. }
  639. let sellAddress = "";
  640. if (formData.data.sellAddress) {
  641. sellAddress = formData.data.sellAddress;
  642. }
  643. formData.data.address =
  644. countryName + ", " + provinceName + ", " + cityName + "," + sellAddress;
  645. } else if (formData.data.deliveryType === "3") {
  646. formData.data.address = "";
  647. }
  648. };
  649. const getCityData = (id, type, isChange) => {
  650. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  651. if (type === "20") {
  652. provinceData.value = res;
  653. if (isChange) {
  654. formData.data.provinceId = "";
  655. formData.data.provinceName = "";
  656. formData.data.cityId = "";
  657. formData.data.cityName = "";
  658. }
  659. } else if (type === "30") {
  660. cityData.value = res;
  661. if (isChange) {
  662. formData.data.cityId = "";
  663. formData.data.cityName = "";
  664. }
  665. } else {
  666. countryData.value = res;
  667. }
  668. });
  669. };
  670. getDict();
  671. getCityData("0");
  672. const buyCorporationIdChange = (val) => {
  673. if (val) {
  674. proxy.post("/corporation/detail", { id: val }).then((res) => {
  675. formData.data.buyCountryName = res.countryName;
  676. formData.data.buyProvinceName = res.provinceName;
  677. formData.data.buyCityName = res.cityName;
  678. formData.data.buyAddress = res.address;
  679. changeAddress();
  680. });
  681. }
  682. };
  683. const changeSupplier = (val) => {
  684. changeProductPrice();
  685. formData.data.countryId = "";
  686. formData.data.provinceId = "";
  687. formData.data.cityId = "";
  688. formData.data.sellAddress = "";
  689. formData.data.sellContactName = "";
  690. formData.data.sellContactNumber = "";
  691. if (val) {
  692. let data = supplierList.value.filter((item) => item.id === val);
  693. if (data && data.length > 0) {
  694. formData.data.countryId = data[0].countryId;
  695. formData.data.provinceId = data[0].provinceId;
  696. formData.data.cityId = data[0].cityId;
  697. formData.data.sellAddress = data[0].areaDetail;
  698. formData.data.sellContactName = data[0].contactPerson;
  699. formData.data.sellContactNumber = data[0].contactNumber;
  700. if (formData.data.countryId) {
  701. getCityData(formData.data.countryId, "20");
  702. }
  703. if (formData.data.provinceId) {
  704. getCityData(formData.data.provinceId, "30");
  705. }
  706. setTimeout(() => changeAddress(), 1500);
  707. }
  708. }
  709. };
  710. const changeProductPrice = () => {
  711. let productIds = formData.data.purchaseProductList.map((x) => x.productId);
  712. if (productIds && productIds.length > 0) {
  713. proxy
  714. .post("/ehsdPurchase/getProductPriceInfo", {
  715. productIds: productIds,
  716. sellCorporationId: formData.data.sellCorporationId
  717. ? formData.data.sellCorporationId
  718. : "",
  719. })
  720. .then((resOne) => {
  721. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  722. const iele = formData.data.purchaseProductList[i];
  723. for (const key in resOne) {
  724. if (iele.productId == key) {
  725. iele.purchaseProductPriceList = resOne[key].purchaseProductList
  726. .map((x) => ({
  727. createTime: x.createTime || "",
  728. price: x.price,
  729. }))
  730. .filter((y, index) => index < 3);
  731. iele.purchaseProductPriceListOne = resOne[
  732. key
  733. ].purchaseProductList.map((x) => ({
  734. createTime: x.createTime || "",
  735. price: x.price,
  736. }));
  737. iele.topPriceList = resOne[key].topPriceList
  738. .map((x) => ({
  739. supplierName: x.supplierName,
  740. price: x.price,
  741. }))
  742. .filter((y, index) => index < 3);
  743. iele.supplyPurchaseProductPriceList = resOne[
  744. key
  745. ].supplyPurchaseProductList
  746. .map((x) => ({
  747. createTime: x.createTime || "",
  748. price: x.price,
  749. }))
  750. .filter((y, index) => index < 3);
  751. }
  752. }
  753. }
  754. });
  755. }
  756. };
  757. const onPicture = (path) => {
  758. window.open(path, "_blank");
  759. };
  760. const handleRemove = (index) => {
  761. formData.data.purchaseProductList.splice(index, 1);
  762. totalAmount();
  763. };
  764. const calculationAmount = (att = "") => {
  765. nextTick(() => {
  766. if (
  767. formData.data.purchaseProductList &&
  768. formData.data.purchaseProductList.length > 0
  769. ) {
  770. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  771. let money = 0;
  772. money = parseFloat(
  773. Number(formData.data.purchaseProductList[i].quantity) *
  774. Number(formData.data.purchaseProductList[i].price)
  775. ).toFixed(2);
  776. formData.data.purchaseProductList[i].amount = money;
  777. }
  778. }
  779. nextTick(() => {
  780. totalAmount();
  781. });
  782. });
  783. };
  784. const totalAmount = () => {
  785. let money = 0;
  786. if (
  787. formData.data.purchaseProductList &&
  788. formData.data.purchaseProductList.length > 0
  789. ) {
  790. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  791. if (formData.data.purchaseProductList[i].amount) {
  792. money = parseFloat(
  793. Number(money) + Number(formData.data.purchaseProductList[i].amount)
  794. ).toFixed(2);
  795. }
  796. }
  797. }
  798. if (
  799. formData.data.purchaseProjectList &&
  800. formData.data.purchaseProjectList.length > 0
  801. ) {
  802. for (let i = 0; i < formData.data.purchaseProjectList.length; i++) {
  803. if (formData.data.purchaseProjectList[i].amount) {
  804. money = parseFloat(
  805. Number(money) + Number(formData.data.purchaseProjectList[i].amount)
  806. ).toFixed(2);
  807. }
  808. }
  809. }
  810. formData.data.amount = money;
  811. };
  812. const clickAdd = () => {
  813. if (
  814. formData.data.purchaseProjectList &&
  815. formData.data.purchaseProjectList.length > 0
  816. ) {
  817. formData.data.purchaseProjectList.push({
  818. payName: "",
  819. amount: null,
  820. remark: "",
  821. });
  822. } else {
  823. formData.data.purchaseProjectList = [
  824. { payName: "", amount: null, remark: "" },
  825. ];
  826. }
  827. };
  828. const handleDelete = (index) => {
  829. formData.data.purchaseProjectList.splice(index, 1);
  830. totalAmount();
  831. };
  832. const querySearch = (queryString, callback) => {
  833. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  834. if (res.rows && res.rows.length > 0) {
  835. res.rows = res.rows.map((item) => {
  836. return {
  837. ...item,
  838. value: item.payName,
  839. };
  840. });
  841. callback(res.rows);
  842. } else {
  843. callback([]);
  844. }
  845. });
  846. };
  847. const loadingSearch = ref(false);
  848. const remoteMethod = (keyword) => {
  849. if (keyword && typeof keyword === "string") {
  850. loadingSearch.value = true;
  851. proxy.post("/supplierInfo/page", { keyword }).then((res) => {
  852. supplierList.value = res.rows.map((x) => ({
  853. ...x,
  854. label: x.name,
  855. value: x.id,
  856. }));
  857. loadingSearch.value = false;
  858. });
  859. }
  860. return;
  861. };
  862. const handleSubmit = async () => {
  863. let flag = await formDom.value.handleSubmit(() => {});
  864. if (flag) {
  865. return true;
  866. } else {
  867. setTimeout(() => {
  868. const errorDiv = document.getElementsByClassName("is-error");
  869. errorDiv[0].scrollIntoView();
  870. }, 0);
  871. }
  872. return flag;
  873. };
  874. const updateContent = (val) => {
  875. formData.data.remark = val;
  876. };
  877. const remarkEditor = ref(null);
  878. const changeContractTemplate = (val) => {
  879. if (val) {
  880. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  881. remarkEditor.value.changeHtml(res.templateContent);
  882. });
  883. }
  884. };
  885. const getFormData = () => {
  886. return proxy.deepClone(formData.data);
  887. };
  888. // 向父组件暴露
  889. defineExpose({
  890. getFormData,
  891. handleSubmit,
  892. });
  893. const getAllData = (businessId) => {
  894. if (businessId) {
  895. proxy.post("/ehsdPurchase/detail", { id: businessId }).then((res) => {
  896. res.countryId = res.sellCountryId;
  897. res.provinceId = res.sellProvinceId;
  898. res.cityId = res.sellCityId;
  899. if (res.grossProfitInfoList && res.grossProfitInfoList.length > 0) {
  900. $bus.emit("getGrossData", res.grossProfitInfoList);
  901. }
  902. for (let key in res) {
  903. if (!["ehsdPurchaseProductList", "purchaseArrivalList"].includes(key)) {
  904. formData.data[key] = res[key];
  905. }
  906. }
  907. remarkEditor.value.changeHtml(formData.data.remark);
  908. if (
  909. formData.data.purchaseProductList &&
  910. formData.data.purchaseProductList.length > 0
  911. ) {
  912. let ids = formData.data.purchaseProductList.map((x) => x.productId);
  913. proxy.getFile(
  914. ids,
  915. formData.data.purchaseProductList,
  916. "productId",
  917. "fileList",
  918. "fileUrl"
  919. );
  920. changeProductPrice();
  921. }
  922. if (formData.data.countryId) {
  923. getCityData(formData.data.countryId, "20");
  924. }
  925. if (formData.data.provinceId) {
  926. getCityData(formData.data.provinceId, "30");
  927. }
  928. });
  929. }
  930. };
  931. const getProductList = (ids) => {
  932. if (ids && ids.length > 0) {
  933. proxy.post("/subscribeDetail/detail", { ids }).then((res) => {
  934. if (res && res.length > 0) {
  935. formData.data.purchaseProductList = res.map((item) => {
  936. let dataResourceId =
  937. item.dataType == 0 ? item.id : item.contractDetailId;
  938. return {
  939. productId: item.productId,
  940. contractId: item.contractId,
  941. productName: item.productName,
  942. productCode: item.productCustomCode,
  943. productLength: item.productLength,
  944. productWidth: item.productWidth,
  945. productHeight: item.productHeight,
  946. subscribeCount: item.count || 0,
  947. purchaseCount: item.purchaseCount || 0,
  948. quantity: null,
  949. price: "",
  950. amount: "",
  951. remark: "",
  952. fileUrl: "",
  953. dataResource: item.dataType,
  954. dataResourceId: dataResourceId,
  955. subscribeDetailId: item.id,
  956. };
  957. });
  958. formData.data.dataResource =
  959. formData.data.purchaseProductList[0].dataResource;
  960. if (formData.data.purchaseProductList[0].dataType == 0) {
  961. formData.data.dataResourceId = res[0].subscribeId;
  962. } else {
  963. formData.data.dataResourceId = res[0].contractId;
  964. }
  965. let productIdList = res.map((x) => x.productId);
  966. proxy
  967. .post("/fileInfo/getList", {
  968. businessIdList: productIdList,
  969. })
  970. .then((fileObj) => {
  971. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  972. const e = formData.data.purchaseProductList[i];
  973. for (const key in fileObj) {
  974. if (e.productId === key) {
  975. if (fileObj[key] && fileObj[key].length > 0) {
  976. e.fileUrl = fileObj[key][0].fileUrl;
  977. }
  978. }
  979. }
  980. }
  981. });
  982. changeProductPrice();
  983. }
  984. });
  985. }
  986. };
  987. onMounted(() => {
  988. formOption.disabled = judgeStatus();
  989. if (route.query && route.query.ids) {
  990. let ids = route.query.ids.split(",");
  991. getProductList(ids);
  992. }
  993. if (route.query.businessId && route.query.processType) {
  994. getAllData(route.query.businessId);
  995. }
  996. });
  997. // watch(
  998. // () => props.queryData,
  999. // (val) => {
  1000. // nextTick(() => {
  1001. // formOption.disabled = judgeStatus();
  1002. // });
  1003. // if (val.businessId && val.processType) {
  1004. // getAllData(val.businessId);
  1005. // }
  1006. // },
  1007. // {
  1008. // deep: true,
  1009. // immediate: true,
  1010. // }
  1011. // );
  1012. const optionTwo = reactive({
  1013. data: {
  1014. tooltip: {
  1015. trigger: "axis",
  1016. },
  1017. // legend: {
  1018. // data: ["价格"],
  1019. // },
  1020. grid: {
  1021. left: "3%",
  1022. right: "4%",
  1023. top: "10%",
  1024. bottom: "3%",
  1025. containLabel: true,
  1026. },
  1027. // toolbox: {
  1028. // feature: {
  1029. // saveAsImage: {},
  1030. // },
  1031. // },
  1032. xAxis: {
  1033. type: "category",
  1034. boundaryGap: false,
  1035. data: [],
  1036. },
  1037. yAxis: {
  1038. type: "value",
  1039. },
  1040. series: [
  1041. {
  1042. name: "价格",
  1043. type: "line",
  1044. data: [],
  1045. },
  1046. ],
  1047. },
  1048. });
  1049. const showEcharts = (row, index) => {
  1050. let myChart = null;
  1051. myChart = echarts.init(document.getElementById(row.productId + index));
  1052. window.addEventListener("resize", () => {
  1053. myChart.resize();
  1054. });
  1055. if (
  1056. row.purchaseProductPriceListOne &&
  1057. row.purchaseProductPriceListOne.length > 0
  1058. ) {
  1059. optionTwo.data.xAxis.data = row.purchaseProductPriceListOne.map((item) => {
  1060. return item.createTime.slice(0, 10);
  1061. });
  1062. optionTwo.data.series[0].data = row.purchaseProductPriceListOne.map(
  1063. (item) => {
  1064. return item.price;
  1065. }
  1066. );
  1067. } else {
  1068. optionTwo.data.xAxis.data = [];
  1069. optionTwo.data.series[0].data = [];
  1070. }
  1071. myChart.setOption(optionTwo.data);
  1072. myChart.resize();
  1073. };
  1074. const clickCopy = (type) => {
  1075. copyType.value = type;
  1076. copyContract.value = true;
  1077. };
  1078. </script>
  1079. <style lang="scss" scoped>
  1080. .img {
  1081. object-fit: contain;
  1082. width: 16px;
  1083. height: 16px;
  1084. vertical-align: middle;
  1085. }
  1086. .pic {
  1087. object-fit: contain;
  1088. width: 50px;
  1089. height: 50px;
  1090. cursor: pointer;
  1091. vertical-align: middle;
  1092. }
  1093. .ql-editor {
  1094. padding: 0px;
  1095. }
  1096. </style>