PurchaseChange.vue 40 KB

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