Purchase.vue 38 KB

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