Purchase.vue 35 KB

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