Purchase.vue 38 KB

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