Purchase.vue 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  4. <template #btn>
  5. <div>
  6. <el-button type="primary" v-if="
  7. route.query.processType==30 || !route.query.processType
  8. " @click="clickCopy">复制采购订单</el-button>
  9. </div>
  10. </template>
  11. <template #buyer>
  12. <div style="width: 100%">
  13. <el-form-item prop="buyCorporationId">
  14. <el-select v-model="formData.data.buyCorporationId" style="width: 100%" @change="changeBuyCorporation">
  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-row style="margin-top: 20px; width: 100%">
  19. <el-col :span="8">
  20. <el-form-item label="地址" prop="buyCountryName">
  21. <el-input v-model="formData.data.buyCountryName" placeholder="请输入国家" @change="changeAddress" />
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="8">
  25. <el-form-item label=" " prop="buyProvinceName">
  26. <el-input v-model="formData.data.buyProvinceName" placeholder="请输入省/州" @change="changeAddress" />
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="8">
  30. <el-form-item label=" " prop="buyCityName">
  31. <el-input v-model="formData.data.buyCityName" placeholder="请输入城市" @change="changeAddress" />
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. <el-row style="margin-top: 20px; width: 100%">
  36. <el-col :span="24">
  37. <el-form-item prop="buyAddress">
  38. <el-input v-model="formData.data.buyAddress" type="textarea" @change="changeAddress" />
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <el-row style="margin-top: 20px; width: 100%">
  43. <el-col :span="8">
  44. <el-form-item label="联系人" prop="buyContactName">
  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">
  50. <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
  51. </el-form-item>
  52. </el-col>
  53. </el-row>
  54. </div>
  55. </template>
  56. <template #seller>
  57. <div style="width: 100%">
  58. <div style="width: 100%">
  59. <el-form-item prop="sellCorporationId">
  60. <el-select v-model="formData.data.sellCorporationId" style="width: 100%" filterable remote reserve-keyword placeholder="请输入关键字"
  61. remote-show-suffix :remote-method="remoteMethod" :loading="loadingSearch" @input="remoteMethod" @change="changeSupplier"
  62. v-if="
  63. route.query.processType==30 ||
  64. !route.query.processType
  65. ">
  66. <el-option v-for="item in supplierList" :key="item.value" :label="item.label" :value="item.value" />
  67. </el-select>
  68. <el-select v-model="formData.data.sellCorporationName" disabled v-else style="width: 100%">
  69. </el-select>
  70. </el-form-item>
  71. <el-row style="margin-top: 20px; width: 100%">
  72. <el-col :span="6">
  73. <el-form-item label="地址" prop="countryId">
  74. <el-select v-model="formData.data.countryId" placeholder="国家" filterable @change="(val) => changeSellAddress(val, '20')">
  75. <el-option v-for="item in countryData" :label="item.chineseName" :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">
  82. <selectCity placeholder="省/洲" @change="(val) => changeSellAddress(val, '30')" 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">
  89. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData"
  90. @change="changeAddress">
  91. </selectCity>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="6">
  95. <el-form-item label=" " prop="sellPostalCode">
  96. <el-input v-model="formData.data.sellPostalCode" placeholder="请输入邮编" />
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. <el-row style="margin-top: 20px; width: 100%">
  101. <el-col :span="24">
  102. <el-form-item prop="sellAddress">
  103. <el-input v-model="formData.data.sellAddress" type="textarea" @change="changeAddress" />
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. <el-row style="margin-top: 20px; width: 100%">
  108. <el-col :span="8">
  109. <el-form-item label="联系人" prop="sellContactName">
  110. <el-input v-model="formData.data.sellContactName" placeholder="请输入联系人" />
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="16">
  114. <el-form-item label=" " prop="sellContactNumber">
  115. <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
  116. </el-form-item>
  117. </el-col>
  118. </el-row>
  119. </div>
  120. </div>
  121. </template>
  122. <template #payment>
  123. <div style="width: 100%">
  124. <el-row style="margin-top: 20px; width: 100%">
  125. <el-col :span="6">
  126. <el-form-item label="付款方式" prop="paymentMethod">
  127. <el-select v-model="formData.data.paymentMethod" placeholder="请选择付款方式" style="width: 100%">
  128. <el-option v-for="item in fundsPaymentMethod" :key="item.value" :label="item.label" :value="item.value" />
  129. </el-select>
  130. </el-form-item>
  131. </el-col>
  132. <el-col :span="6">
  133. <el-form-item label="发票类型" prop="invoiceType">
  134. <el-select v-model="formData.data.invoiceType" placeholder="请选择发票类型" style="width: 100%">
  135. <el-option v-for="item in invoiceType" :key="item.value" :label="item.label" :value="item.value" />
  136. </el-select>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. </div>
  141. </template>
  142. <template #delivery>
  143. <div style="width: 100%">
  144. <el-row style="margin-top: 20px; width: 100%">
  145. <el-col :span="12">
  146. <el-form-item label="交货类型" prop="deliveryType">
  147. <el-radio-group v-model="formData.data.deliveryType" @change="changeAddress">
  148. <el-radio v-for="(item, index) in deliveryType" :key="index" :label="item.value" border>{{ item.label }}</el-radio>
  149. </el-radio-group>
  150. </el-form-item>
  151. </el-col>
  152. </el-row>
  153. <el-row style="margin-top: 20px; width: 100%">
  154. <el-col :span="12">
  155. <el-form-item label="详细地址" prop="address">
  156. <el-input v-model="formData.data.address" :rows="2" type="textarea" placeholder="请输入详细地址" />
  157. </el-form-item>
  158. </el-col>
  159. </el-row>
  160. <el-row style="margin-top: 20px; width: 100%">
  161. <el-col :span="6">
  162. <el-form-item label="交付日期" prop="deliveryTime">
  163. <el-date-picker v-model="formData.data.deliveryTime" type="date" placeholder="请选择交付日期" value-format="YYYY-MM-DD" />
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="6">
  167. <el-form-item label="质保期 (天)" prop="warranty">
  168. <el-input-number onmousewheel="return false;" v-model="formData.data.warranty" placeholder="请输入质保期" style="width: 100%" :precision="0"
  169. :controls="false" :min="0" />
  170. </el-form-item>
  171. </el-col>
  172. </el-row>
  173. </div>
  174. </template>
  175. <template #commodity>
  176. <div style="width: 100%" v-if="
  177. formData.data.purchaseProductList &&
  178. formData.data.purchaseProductList.length > 0
  179. ">
  180. <div :style="
  181. index !== formData.data.purchaseProductList.length - 1
  182. ? 'margin-bottom: 20px'
  183. : ''
  184. " v-for="(item, index) in formData.data.purchaseProductList" :key="item.dataResourceId">
  185. <div style="
  186. border: 1px solid #ccc;
  187. padding: 20px 10px 0 10px;
  188. width: 100%;
  189. ">
  190. <el-row style="
  191. width: 100%;
  192. font-weight: 700;
  193. background: #eee;
  194. padding: 10px 0px;
  195. " :gutter="5" type="flex" align="middle">
  196. <el-col :span="1" style="text-align: center">
  197. <img v-if="item.fileUrl" :src="item.fileUrl" class="pic" style="width: 30px; height: 30px" @click="onPicture(item.fileUrl)" />
  198. </el-col>
  199. <el-col :span="4">
  200. <span>产品名称: {{ item.productName }}</span>
  201. </el-col>
  202. <el-col :span="4">
  203. <span>尺寸: {{ item.productModel }}</span>
  204. </el-col>
  205. <el-col :span="3"> </el-col>
  206. <el-col :span="2">
  207. <span>数量: {{ item.quantity }}</span>
  208. </el-col>
  209. <el-col :span="3">
  210. <span>单价: {{ item.price }}</span>
  211. </el-col>
  212. <el-col :span="3">
  213. <span>金额小计: {{ item.amount }}</span>
  214. </el-col>
  215. <el-col :span="2">
  216. <!-- <el-button
  217. type="primary"
  218. text
  219. @click="handleHandover(item, index)"
  220. >编辑备注</el-button
  221. > -->
  222. <div style="color: #409eff; cursor: pointer" @click="handleHandover(item, index)">
  223. 编辑备注
  224. </div>
  225. </el-col>
  226. <el-col :span="2">
  227. <el-button type="primary" text @click="handleMaterial(index)">添加配件</el-button>
  228. </el-col>
  229. </el-row>
  230. <el-collapse v-model="item.activeName" class="hideCollapse" accordion>
  231. <el-collapse-item title="" :name="true">
  232. <div style="padding: 0 40px">
  233. <el-table :data="item.purchaseProductMountingsList" style="width: 100%">
  234. <el-table-column label="图片" align="center" width="80">
  235. <template #default="{ row }">
  236. <img v-if="row.fileUrl" :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  237. </template>
  238. </el-table-column>
  239. <el-table-column label="类型" align="center" width="80">
  240. <template #default="{ row }">
  241. <div>
  242. {{ dictValueLabel(row.productType, productType) }}
  243. </div>
  244. </template>
  245. </el-table-column>
  246. <el-table-column label="产品名称" prop="productName" min-width="180" />
  247. <el-table-column label="尺寸" prop="productModel" min-width="140" />
  248. <el-table-column label="单价" width="160">
  249. <template #default="{ row, $index }">
  250. <div style="width: 100%" class="removePadding">
  251. <el-form-item :prop="
  252. 'purchaseProductList.' +
  253. index +
  254. '.purchaseProductMountingsList.' +
  255. $index +
  256. '.price'
  257. " :rules="rules.price" :inline-message="true" @change="
  258. () => {
  259. return changeProductMaterial(index, $index);
  260. }
  261. ">
  262. <div style="display:flex">
  263. <el-input-number onmousewheel="return false;" v-model="row.price" style="width: 100%" placeholder="请输入单价"
  264. :precision="2" :controls="false" :min="0" />
  265. <el-popover placement="top-start" :width="400" trigger="hover" @show="showEcharts(row,$index)">
  266. <template #default>
  267. <div>
  268. <div>
  269. <img src="@/assets/images/money1.png" alt="" class="img" />
  270. <span style="font-size:14px;font-weight:700;color:#000"> 该供应商近期采购单价:</span>
  271. <div style="padding:5px 0px 0px 20px">
  272. <div v-for="(item,index) in row.supplyPurchaseProductPriceList" :key="index">
  273. <span>{{item.createTime.slice(0,10)}} </span>
  274. <span style="margin-left:40px">CNY {{moneyFormat(item.price,2)}} </span>
  275. </div>
  276. </div>
  277. </div>
  278. <div style="margin-top:15px">
  279. <img src="@/assets/images/money2.png" alt="" class="img" />
  280. <span style="font-size:14px;font-weight:700;color:#000"> 供货推荐:</span>
  281. <div style="padding:5px 0px 0px 20px">
  282. <div v-for="(item,index) in row.topPriceList " :key="index">
  283. <span>{{item.supplierName}} </span>
  284. <span style="margin-left:40px"> CNY {{moneyFormat(item.price,2)}} </span>
  285. </div>
  286. </div>
  287. </div>
  288. <div style="margin-top:15px">
  289. <img src="@/assets/images/money3.png" alt="" class="img" />
  290. <span style="font-size:14px;font-weight:700;color:#000"> 近期采购单价:</span>
  291. <div style="padding:5px 0px 0px 20px">
  292. <div v-for="(item,index) in row.purchaseProductPriceList " :key="index">
  293. <span>{{item.createTime.slice(0,10)}} </span>
  294. <span style="margin-left:40px"> CNY {{moneyFormat(item.price,2)}} </span>
  295. </div>
  296. </div>
  297. </div>
  298. <div :ref="row.productId+$index" :id="row.productId+$index" style="height:180px">
  299. </div>
  300. </div>
  301. </template>
  302. <template #reference>
  303. <div style="margin-left:10px;cursor:pointer;position:relative;top:4px">
  304. <el-icon :size="20" color="#85c1a6">
  305. <WarningFilled />
  306. </el-icon>
  307. </div>
  308. </template>
  309. </el-popover>
  310. </div>
  311. </el-form-item>
  312. </div>
  313. </template>
  314. </el-table-column>
  315. <el-table-column label="数量" width="140">
  316. <template #default="{ row, $index }">
  317. <div style="width: 100%" class="removePadding">
  318. <el-form-item :prop="
  319. 'purchaseProductList.' +
  320. index +
  321. '.purchaseProductMountingsList.' +
  322. $index +
  323. '.quantity'
  324. " :rules="rules.quantity" :inline-message="true" @change="
  325. () => {
  326. return changeProductMaterial(index, $index);
  327. }
  328. ">
  329. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入数量" :precision="0"
  330. :controls="false" :min="0" />
  331. </el-form-item>
  332. </div>
  333. </template>
  334. </el-table-column>
  335. <el-table-column label="金额" prop="amount" width="100" />
  336. <el-table-column label="操作" align="center" width="80" fixed="right">
  337. <template #default="{ $index }">
  338. <el-button type="primary" v-if="$index !== 0" link @click="handleRemove(index, $index)">删除</el-button>
  339. </template>
  340. </el-table-column>
  341. </el-table>
  342. </div>
  343. </el-collapse-item>
  344. </el-collapse>
  345. <div style="text-align: center; margin-top: -18px">
  346. <el-button type="primary" @click="item.activeName = !item.activeName" style="margin-bottom: -28px; background: #fff" text>
  347. <span v-if="item.activeName">
  348. <span style="vertical-align: middle">收起明细</span>
  349. <el-icon style="
  350. margin-left: 8px;
  351. transform: rotate(-90deg);
  352. vertical-align: middle;
  353. ">
  354. <DArrowRight />
  355. </el-icon>
  356. </span>
  357. <span v-else>
  358. <span style="vertical-align: middle">查看明细</span>
  359. <el-icon style="
  360. margin-left: 8px;
  361. transform: rotate(90deg);
  362. vertical-align: middle;
  363. ">
  364. <DArrowRight />
  365. </el-icon>
  366. </span>
  367. </el-button>
  368. </div>
  369. </div>
  370. </div>
  371. </div>
  372. </template>
  373. <template #otherCharge>
  374. <div style="width: 100%">
  375. <el-button type="primary" @click="clickAdd()">添加行</el-button>
  376. <el-table :data="formData.data.purchaseProjectList" style="width: 100%; margin-top: 16px">
  377. <el-table-column label="收费项目" width="220">
  378. <template #default="{ row, $index }">
  379. <div style="width: 100%">
  380. <el-form-item :prop="'purchaseProjectList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true">
  381. <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50"
  382. placeholder="请输入收费项目" />
  383. </el-form-item>
  384. </div>
  385. </template>
  386. </el-table-column>
  387. <el-table-column label="备注">
  388. <template #default="{ row, $index }">
  389. <div style="width: 100%">
  390. <el-form-item :prop="'purchaseProjectList.' + $index + '.remark'">
  391. <el-input v-model="row.remark" placeholder="请输入备注" />
  392. </el-form-item>
  393. </div>
  394. </template>
  395. </el-table-column>
  396. <el-table-column label="金额" width="130">
  397. <template #default="{ row, $index }">
  398. <div style="width: 100%">
  399. <el-form-item :prop="'purchaseProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true" class="shrinkPadding"
  400. @change="changeProject">
  401. <el-input-number onmousewheel="return false;" v-model="row.amount" placeholder="请输入金额" style="width: 100%" :precision="2"
  402. :controls="false" />
  403. </el-form-item>
  404. </div>
  405. </template>
  406. </el-table-column>
  407. <el-table-column label="操作" width="60" align="center" fixed="right">
  408. <template #default="{ $index }">
  409. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  410. </template>
  411. </el-table-column>
  412. </el-table>
  413. </div>
  414. </template>
  415. <template #offerMoney>
  416. <div style="width: 100%; display: flex">
  417. <div style="width: calc(100% - 190px)"></div>
  418. <div style="width: 130px; padding: 0 12px">
  419. <el-form-item label="合同总金额" prop="amount" class="shrinkPadding">
  420. <el-input v-model="formData.data.amount" placeholder="合同总金额" disabled />
  421. </el-form-item>
  422. </div>
  423. </div>
  424. </template>
  425. <template #contractClause>
  426. <div style="width: 100%">
  427. <el-row style="margin-top: 20px; width: 100%">
  428. <el-col :span="8">
  429. <el-form-item label="合同模板" prop="contractTemplateId">
  430. <el-select v-model="formData.data.contractTemplateId" style="width: 100%" @change="changeContractTemplate">
  431. <el-option v-for="item in templateList" :key="item.value" :label="item.label" :value="item.value" />
  432. </el-select>
  433. </el-form-item>
  434. </el-col>
  435. </el-row>
  436. <div style="margin-top: 20px; width: 100%">
  437. <el-form-item label="条款内容" prop="remark">
  438. <!-- <div v-if="judgeStatus()">
  439. <div v-html="getHtmlVal(formData.data.remark)"></div>
  440. </div> -->
  441. <Editor style="width: 100%" :value="formData.data.remark" @updateValue="updateContent" :readOnly="judgeStatus()" ref="remarkEditor" />
  442. </el-form-item>
  443. </div>
  444. </div>
  445. </template>
  446. <template #shipment>
  447. <div style="width: 100%">
  448. <el-table :data="formData.data.purchaseArrivalList" style="width: 100%; margin-top: 16px">
  449. <el-table-column prop="productCode" label="商品编码" width="120" />
  450. <el-table-column prop="productName" label="商品名称" />
  451. <el-table-column label="到货日期" width="220">
  452. <template #default="{ row, $index }">
  453. <div style="width: 100%">
  454. <el-form-item :prop="'purchaseArrivalList.' + $index + '.arrivalTime'" :rules="rules.arrivalTime" :inline-message="true">
  455. <el-date-picker v-model="row.arrivalTime" type="date" placeholder="请选择到货日期" value-format="YYYY-MM-DD" />
  456. </el-form-item>
  457. </div>
  458. </template>
  459. </el-table-column>
  460. <el-table-column label="到货数量" width="160">
  461. <template #default="{ row, $index }">
  462. <div style="width: 100%">
  463. <el-form-item :prop="'purchaseArrivalList.' + $index + '.quantity'" :inline-message="true">
  464. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入到货数量" style="width: 100%" :precision="0"
  465. :controls="false" :min="0" />
  466. </el-form-item>
  467. </div>
  468. </template>
  469. </el-table-column>
  470. <el-table-column align="center" label="操作" width="120" fixed="right">
  471. <template #default="{ row, $index }">
  472. <el-button type="primary" link @click="clickSplit(row)">拆分</el-button>
  473. <el-button type="primary" link @click="clickDelete($index)">删除</el-button>
  474. </template>
  475. </el-table-column>
  476. </el-table>
  477. </div>
  478. </template>
  479. </byForm>
  480. <el-dialog v-if="openMaterialCompany" v-model="openMaterialCompany" title="物料选择" width="90%" append-to-body>
  481. <SelectMaterial :alreadySelectData="alreadySelectData" @handleSelect="selectMaterial"></SelectMaterial>
  482. </el-dialog>
  483. <el-dialog title="备注" v-if="openHandover" v-model="openHandover" width="800">
  484. <byForm :formConfig="formHandoverConfig" :formOption="formOption" v-model="productRow.data">
  485. <template #file>
  486. <div style="width: 100%">
  487. <el-upload v-model:fileList="fileList" :action="uploadUrl" :data="uploadData" multiple :before-upload="uploadFile"
  488. :on-success="handleSuccess" :on-preview="onPreviewFile">
  489. <el-button>选择</el-button>
  490. </el-upload>
  491. </div>
  492. </template>
  493. <template #remark>
  494. <div style="width: 100%">
  495. <Editor :value="productRow.data.remark" @updateValue="updateHandover" />
  496. </div>
  497. </template>
  498. </byForm>
  499. <template #footer>
  500. <el-button @click="openHandover = false" size="default">取 消</el-button>
  501. <el-button type="primary" @click="submitHandoverForm()" size="default">确 定</el-button>
  502. </template>
  503. </el-dialog>
  504. <el-dialog v-if="copyContract" v-model="copyContract" title="采购订单选择" width="90%" append-to-body>
  505. <SelectPurchase @select="selectPurchase"></SelectPurchase>
  506. </el-dialog>
  507. </div>
  508. </template>
  509. <script setup>
  510. import byForm from "@/components/byForm/index";
  511. import SelectMaterial from "@/components/product/SelectMaterial.vue";
  512. import SelectPurchase from "@/components/contractCom/selectPurchase.vue";
  513. import { ElMessage } from "element-plus";
  514. import selectCity from "@/components/selectCity/index.vue";
  515. import Editor from "@/components/Editor/index.vue";
  516. import { useRoute } from "vue-router";
  517. import useUserStore from "@/store/modules/user";
  518. import * as echarts from "echarts";
  519. import $bus from "@/bus/index.js";
  520. const alreadySelectData = ref([]);
  521. const userInfo = useUserStore();
  522. const route = useRoute();
  523. const { proxy } = getCurrentInstance();
  524. const invoiceType = ref([]);
  525. const fundsPaymentMethod = ref([]);
  526. const templateList = ref([]);
  527. const corporationList = ref([]);
  528. const supplierList = ref([]);
  529. const countryData = ref([]);
  530. const provinceData = ref([]);
  531. const cityData = ref([]);
  532. const openMaterialCompany = ref(false);
  533. const copyContract = ref(false);
  534. const formData = reactive({
  535. data: {
  536. deliveryType: "1",
  537. remark: "",
  538. amount: undefined,
  539. purchaseArrivalList: [],
  540. purchaseProductList: [],
  541. purchaseProjectList: [],
  542. },
  543. });
  544. const submit = ref(null);
  545. const deliveryType = ref([
  546. {
  547. label: "买方地址",
  548. value: "1",
  549. },
  550. {
  551. label: "工厂交付",
  552. value: "2",
  553. },
  554. {
  555. label: "其他",
  556. value: "3",
  557. },
  558. ]);
  559. const productType = ref([
  560. {
  561. label: "产品",
  562. value: 1,
  563. },
  564. {
  565. label: "物料",
  566. value: 2,
  567. },
  568. ]);
  569. const judgeStatus = () => {
  570. if (route.query.processType == 20 || route.query.processType == 10) {
  571. return true;
  572. }
  573. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  574. let data = props.queryData.recordList.filter(
  575. (item) => item.status === 2 && item.nodeType !== 1
  576. );
  577. if (data && data.length > 0) {
  578. return true;
  579. }
  580. }
  581. return false;
  582. };
  583. const formOption = reactive({
  584. inline: true,
  585. labelWidth: 100,
  586. itemWidth: 100,
  587. rules: [],
  588. disabled: false,
  589. });
  590. const formConfig = computed(() => {
  591. return [
  592. {
  593. type: "slot",
  594. slotName: "btn",
  595. label: "",
  596. },
  597. {
  598. type: "slot",
  599. slotName: "buyer",
  600. label: "买方信息",
  601. itemWidth: 50,
  602. },
  603. {
  604. type: "slot",
  605. slotName: "seller",
  606. label: "卖方信息",
  607. itemWidth: 50,
  608. },
  609. {
  610. type: "title",
  611. title: "付款信息",
  612. haveLine: true,
  613. },
  614. {
  615. type: "slot",
  616. slotName: "payment",
  617. label: "",
  618. },
  619. {
  620. type: "title",
  621. title: "交付信息",
  622. haveLine: true,
  623. },
  624. {
  625. type: "slot",
  626. slotName: "delivery",
  627. label: "",
  628. },
  629. {
  630. type: "title",
  631. title: "采购明细",
  632. haveLine: true,
  633. },
  634. {
  635. type: "slot",
  636. slotName: "commodity",
  637. label: "",
  638. },
  639. {
  640. type: "title",
  641. title: "其他收费项目",
  642. haveLine: true,
  643. },
  644. {
  645. type: "slot",
  646. slotName: "otherCharge",
  647. label: "",
  648. },
  649. {
  650. type: "slot",
  651. slotName: "offerMoney",
  652. },
  653. {
  654. type: "title",
  655. title: "合同条款",
  656. haveLine: true,
  657. },
  658. {
  659. type: "slot",
  660. slotName: "contractClause",
  661. label: "",
  662. },
  663. {
  664. type: "title",
  665. title: "到货要求",
  666. haveLine: true,
  667. },
  668. {
  669. type: "slot",
  670. slotName: "shipment",
  671. label: "",
  672. },
  673. ];
  674. });
  675. const rules = ref({
  676. buyCorporationId: [
  677. { required: true, message: "请选择买方公司", trigger: "change" },
  678. ],
  679. sellCorporationId: [
  680. { required: true, message: "请选择卖方公司", trigger: "change" },
  681. ],
  682. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  683. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  684. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  685. sellContactName: [
  686. { required: true, message: "请输入联系人", trigger: "blur" },
  687. ],
  688. sellContactNumber: [
  689. { required: true, message: "请输入联系电话", trigger: "blur" },
  690. ],
  691. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  692. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  693. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  694. payName: [
  695. { required: true, message: "请输入收费项目", trigger: ["change", "blur"] },
  696. ],
  697. warranty: [{ required: true, message: "请输入质保期", trigger: "blur" }],
  698. deliveryType: [
  699. { required: true, message: "请选择交货类型", trigger: "change" },
  700. ],
  701. address: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  702. deliveryTime: [
  703. { required: true, message: "请选择交付日期", trigger: "change" },
  704. ],
  705. paymentMethod: [
  706. { required: true, message: "请选择付款方式", trigger: "change" },
  707. ],
  708. invoiceType: [
  709. { required: true, message: "请选择发票类型", trigger: "change" },
  710. ],
  711. contractTemplateId: [
  712. { required: true, message: "请选择合同模板", trigger: "change" },
  713. ],
  714. remark: [{ required: true, message: "请输入条款内容", trigger: "change" }],
  715. });
  716. const getDict = () => {
  717. proxy.getDictOne(["invoice_type", "funds_payment_method"]).then((res) => {
  718. invoiceType.value = res["invoice_type"].map((x) => ({
  719. label: x.dictValue,
  720. value: x.dictKey,
  721. }));
  722. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  723. label: x.dictValue,
  724. value: x.dictKey,
  725. }));
  726. });
  727. proxy
  728. .post("/contractTemplate/page", { pageNum: 1, pageSize: 999 })
  729. .then((res) => {
  730. templateList.value = res.rows.map((item) => {
  731. return {
  732. ...item,
  733. label: item.templateName,
  734. value: item.id,
  735. };
  736. });
  737. });
  738. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  739. corporationList.value = res.rows.map((item) => {
  740. return {
  741. ...item,
  742. label: item.name,
  743. value: item.id,
  744. };
  745. });
  746. });
  747. proxy.post("/supplierInfo/page", { pageNum: 1, pageSize: 50 }).then((res) => {
  748. supplierList.value = res.rows.map((item) => {
  749. return {
  750. ...item,
  751. label: item.name,
  752. value: item.id,
  753. };
  754. });
  755. });
  756. };
  757. getDict();
  758. const getCityData = (id, type, isChange) => {
  759. return proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  760. if (type === "20") {
  761. provinceData.value = res;
  762. if (isChange) {
  763. formData.data.provinceId = "";
  764. formData.data.provinceName = "";
  765. formData.data.cityId = "";
  766. formData.data.cityName = "";
  767. }
  768. } else if (type === "30") {
  769. cityData.value = res;
  770. if (isChange) {
  771. formData.data.cityId = "";
  772. formData.data.cityName = "";
  773. }
  774. } else {
  775. countryData.value = res;
  776. }
  777. });
  778. };
  779. getCityData("0");
  780. const changeBuyCorporation = (val) => {
  781. formData.data.buyCountryName = "";
  782. formData.data.buyProvinceName = "";
  783. formData.data.buyCityName = "";
  784. formData.data.buyAddress = "";
  785. if (val) {
  786. proxy.post("/corporation/detail", { id: val }).then((res) => {
  787. formData.data.buyAddress = res.address;
  788. Promise.all([
  789. getBuyCountryName(res.countryId),
  790. getBuyProvinceName(res.provinceId, res.countryId),
  791. getBuyCityName(res.cityId, res.provinceId),
  792. ]).then(() => {
  793. changeAddress();
  794. });
  795. });
  796. }
  797. };
  798. const changeAddress = () => {
  799. if (formData.data.deliveryType === "1") {
  800. let buyCountryName = "";
  801. if (formData.data.buyCountryName) {
  802. buyCountryName = formData.data.buyCountryName;
  803. }
  804. let buyProvinceName = "";
  805. if (formData.data.buyProvinceName) {
  806. buyProvinceName = formData.data.buyProvinceName;
  807. }
  808. let buyCityName = "";
  809. if (formData.data.buyCityName) {
  810. buyCityName = formData.data.buyCityName;
  811. }
  812. let buyAddress = "";
  813. if (formData.data.buyAddress) {
  814. buyAddress = formData.data.buyAddress;
  815. }
  816. formData.data.address =
  817. buyCountryName +
  818. ", " +
  819. buyProvinceName +
  820. ", " +
  821. buyCityName +
  822. "," +
  823. buyAddress;
  824. } else if (formData.data.deliveryType === "2") {
  825. let countryName = "";
  826. if (formData.data.countryId) {
  827. let data = countryData.value.filter(
  828. (item) => item.id === formData.data.countryId
  829. );
  830. if (data && data.length > 0) countryName = data[0].chineseName;
  831. }
  832. let provinceName = "";
  833. if (formData.data.provinceId) {
  834. let data = provinceData.value.filter(
  835. (item) => item.id === formData.data.provinceId
  836. );
  837. if (data && data.length > 0) provinceName = data[0].name;
  838. } else {
  839. if (formData.data.provinceName) {
  840. provinceName = formData.data.provinceName;
  841. }
  842. }
  843. let cityName = "";
  844. if (formData.data.cityId) {
  845. let data = cityData.value.filter(
  846. (item) => item.id === formData.data.cityId
  847. );
  848. if (data && data.length > 0) cityName = data[0].name;
  849. } else {
  850. if (formData.data.cityName) {
  851. cityName = formData.data.cityName;
  852. }
  853. }
  854. let sellAddress = "";
  855. if (formData.data.sellAddress) {
  856. sellAddress = formData.data.sellAddress;
  857. }
  858. formData.data.address =
  859. countryName + ", " + provinceName + ", " + cityName + "," + sellAddress;
  860. } else if (formData.data.deliveryType === "3") {
  861. formData.data.address = "";
  862. }
  863. };
  864. const changeSellAddress = (val, index) => {
  865. Promise.all([getCityData(val, index, true)]).then(() => {
  866. changeAddress();
  867. });
  868. };
  869. const getBuyCountryName = (val) => {
  870. return proxy
  871. .post("/customizeArea/list", { parentId: "0" })
  872. .then((resCountry) => {
  873. let buyCountryData = resCountry.filter((item) => item.id === val);
  874. if (buyCountryData && buyCountryData.length > 0) {
  875. formData.data.buyCountryName = buyCountryData[0].chineseName;
  876. } else {
  877. formData.data.buyCountryName = "";
  878. }
  879. });
  880. };
  881. const getBuyProvinceName = (val, countryId) => {
  882. if (val) {
  883. return proxy
  884. .post("/customizeArea/list", { parentId: countryId })
  885. .then((resProvince) => {
  886. let buyProvinceData = resProvince.filter((item) => item.id === val);
  887. if (buyProvinceData && buyProvinceData.length > 0) {
  888. formData.data.buyProvinceName = buyProvinceData[0].name;
  889. } else {
  890. formData.data.buyProvinceName = "";
  891. }
  892. });
  893. } else {
  894. formData.data.buyProvinceName = "";
  895. return;
  896. }
  897. };
  898. const getBuyCityName = (val, provinceId) => {
  899. if (val) {
  900. return proxy
  901. .post("/customizeArea/list", { parentId: provinceId })
  902. .then((resCity) => {
  903. let buyCityData = resCity.filter((item) => item.id === val);
  904. if (buyCityData && buyCityData.length > 0) {
  905. formData.data.buyCityName = buyCityData[0].name;
  906. } else {
  907. formData.data.buyCityName = "";
  908. }
  909. });
  910. } else {
  911. formData.data.buyCityName = "";
  912. return;
  913. }
  914. };
  915. const changeProductPrice = () => {
  916. let productIds = [];
  917. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  918. const iele = formData.data.purchaseProductList[i];
  919. for (let j = 0; j < iele.purchaseProductMountingsList.length; j++) {
  920. const jele = iele.purchaseProductMountingsList[j];
  921. productIds.push(jele.productId);
  922. }
  923. }
  924. if (productIds && productIds.length > 0) {
  925. proxy
  926. .post("/ehsdPurchase/getProductPriceInfo", {
  927. productIds: productIds,
  928. sellCorporationId: formData.data.sellCorporationId
  929. ? formData.data.sellCorporationId
  930. : "",
  931. })
  932. .then((resOne) => {
  933. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  934. const iele = formData.data.purchaseProductList[i];
  935. for (let j = 0; j < iele.purchaseProductMountingsList.length; j++) {
  936. const jele = iele.purchaseProductMountingsList[j];
  937. for (const key in resOne) {
  938. if (jele.productId == key) {
  939. jele.purchaseProductPriceList = resOne[key].purchaseProductList
  940. .map((x) => ({
  941. createTime: x.createTime,
  942. price: x.price,
  943. }))
  944. .filter((y, index) => index < 3);
  945. jele.purchaseProductPriceListOne = resOne[
  946. key
  947. ].purchaseProductList.map((x) => ({
  948. createTime: x.createTime,
  949. price: x.price,
  950. }));
  951. jele.topPriceList = resOne[key].topPriceList
  952. .map((x) => ({
  953. supplierName: x.supplierName,
  954. price: x.price,
  955. }))
  956. .filter((y, index) => index < 3);
  957. jele.supplyPurchaseProductPriceList = resOne[
  958. key
  959. ].supplyPurchaseProductList
  960. .map((x) => ({
  961. createTime: x.createTime,
  962. price: x.price,
  963. }))
  964. .filter((y, index) => index < 3);
  965. }
  966. }
  967. }
  968. }
  969. });
  970. }
  971. };
  972. const changeSupplier = (val) => {
  973. changeProductPrice();
  974. formData.data.countryId = "";
  975. formData.data.provinceId = "";
  976. formData.data.cityId = "";
  977. formData.data.sellPostalCode = "";
  978. formData.data.sellAddress = "";
  979. formData.data.sellContactName = "";
  980. formData.data.sellContactNumber = "";
  981. if (val) {
  982. let data = supplierList.value.filter((item) => item.id === val);
  983. if (data && data.length > 0) {
  984. formData.data.countryId = data[0].countryId;
  985. formData.data.provinceId = data[0].provinceId;
  986. formData.data.cityId = data[0].cityId;
  987. formData.data.sellAddress = data[0].areaDetail;
  988. formData.data.sellContactName = data[0].contactPerson;
  989. formData.data.sellContactNumber = data[0].contactNumber;
  990. if (formData.data.provinceId) {
  991. Promise.all([
  992. getCityData(formData.data.countryId, "20"),
  993. getCityData(formData.data.provinceId, "30"),
  994. ]).then(() => {
  995. changeAddress();
  996. });
  997. } else {
  998. Promise.all([getCityData(formData.data.countryId, "20")]).then(() => {
  999. changeAddress();
  1000. });
  1001. }
  1002. }
  1003. const ids = formData.data.purchaseProductList.map((x) => x.productId);
  1004. getAuxiliaryData(val, ids);
  1005. }
  1006. };
  1007. const onPicture = (path) => {
  1008. window.open(path, "_blank");
  1009. };
  1010. const changeProject = () => {
  1011. nextTick(() => {
  1012. calculationAllAmount();
  1013. });
  1014. };
  1015. const calculationAllAmount = () => {
  1016. let amount = 0;
  1017. if (
  1018. formData.data.purchaseProductList &&
  1019. formData.data.purchaseProductList.length > 0
  1020. ) {
  1021. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1022. if (formData.data.purchaseProductList[i].amount) {
  1023. amount = Number(
  1024. parseFloat(
  1025. Number(amount) + Number(formData.data.purchaseProductList[i].amount)
  1026. ).toFixed(2)
  1027. );
  1028. }
  1029. }
  1030. }
  1031. if (
  1032. formData.data.purchaseProjectList &&
  1033. formData.data.purchaseProjectList.length > 0
  1034. ) {
  1035. for (let i = 0; i < formData.data.purchaseProjectList.length; i++) {
  1036. if (formData.data.purchaseProjectList[i].amount) {
  1037. amount = Number(
  1038. parseFloat(
  1039. Number(amount) + Number(formData.data.purchaseProjectList[i].amount)
  1040. ).toFixed(2)
  1041. );
  1042. }
  1043. }
  1044. }
  1045. formData.data.amount = amount;
  1046. };
  1047. const calculationProductAmount = (index) => {
  1048. if (
  1049. formData.data.purchaseProductList &&
  1050. formData.data.purchaseProductList.length > 0 &&
  1051. formData.data.purchaseProductList[index].purchaseProductMountingsList &&
  1052. formData.data.purchaseProductList[index].purchaseProductMountingsList
  1053. .length > 0
  1054. ) {
  1055. let amount = 0;
  1056. for (
  1057. let i = 0;
  1058. i <
  1059. formData.data.purchaseProductList[index].purchaseProductMountingsList
  1060. .length;
  1061. i++
  1062. ) {
  1063. if (
  1064. formData.data.purchaseProductList[index].purchaseProductMountingsList[i]
  1065. .amount
  1066. ) {
  1067. amount = Number(
  1068. parseFloat(
  1069. Number(amount) +
  1070. Number(
  1071. formData.data.purchaseProductList[index]
  1072. .purchaseProductMountingsList[i].amount
  1073. )
  1074. ).toFixed(2)
  1075. );
  1076. }
  1077. }
  1078. formData.data.purchaseProductList[index].amount = amount;
  1079. let price = 0;
  1080. if (formData.data.purchaseProductList[index].quantity && amount) {
  1081. price = Number(
  1082. parseFloat(
  1083. Number(amount) /
  1084. Number(formData.data.purchaseProductList[index].quantity)
  1085. ).toFixed(4)
  1086. );
  1087. }
  1088. formData.data.purchaseProductList[index].price = price;
  1089. }
  1090. nextTick(() => {
  1091. calculationAllAmount();
  1092. });
  1093. };
  1094. const changeProductMaterial = (index, indexTwo) => {
  1095. nextTick(() => {
  1096. if (
  1097. formData.data.purchaseProductList &&
  1098. formData.data.purchaseProductList.length > 0 &&
  1099. formData.data.purchaseProductList[index].purchaseProductMountingsList &&
  1100. formData.data.purchaseProductList[index].purchaseProductMountingsList
  1101. .length > 0
  1102. ) {
  1103. if (
  1104. indexTwo === 0 &&
  1105. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1106. indexTwo
  1107. ].quantity
  1108. ) {
  1109. formData.data.purchaseProductList[index].quantity =
  1110. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1111. indexTwo
  1112. ].quantity;
  1113. }
  1114. if (
  1115. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1116. indexTwo
  1117. ].quantity &&
  1118. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1119. indexTwo
  1120. ].price
  1121. ) {
  1122. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1123. indexTwo
  1124. ].amount = Number(
  1125. parseFloat(
  1126. Number(
  1127. formData.data.purchaseProductList[index]
  1128. .purchaseProductMountingsList[indexTwo].quantity
  1129. ) *
  1130. Number(
  1131. formData.data.purchaseProductList[index]
  1132. .purchaseProductMountingsList[indexTwo].price
  1133. )
  1134. ).toFixed(2)
  1135. );
  1136. } else {
  1137. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1138. indexTwo
  1139. ].amount = 0;
  1140. }
  1141. }
  1142. nextTick(() => {
  1143. calculationProductAmount(index);
  1144. });
  1145. });
  1146. };
  1147. const handleRemove = async (index, indexTwo) => {
  1148. await formData.data.purchaseProductList[
  1149. index
  1150. ].purchaseProductMountingsList.splice(indexTwo, 1);
  1151. nextTick(() => {
  1152. calculationProductAmount(index);
  1153. });
  1154. };
  1155. const clickAdd = () => {
  1156. if (
  1157. formData.data.purchaseProjectList &&
  1158. formData.data.purchaseProjectList.length > 0
  1159. ) {
  1160. formData.data.purchaseProjectList.push({
  1161. payName: "",
  1162. amount: undefined,
  1163. remark: "",
  1164. });
  1165. } else {
  1166. formData.data.purchaseProjectList = [
  1167. { payName: "", amount: undefined, remark: "" },
  1168. ];
  1169. }
  1170. };
  1171. const handleDelete = async (index) => {
  1172. await formData.data.purchaseProjectList.splice(index, 1);
  1173. nextTick(() => {
  1174. calculationAllAmount();
  1175. });
  1176. };
  1177. const querySearch = (queryString, callback) => {
  1178. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  1179. if (res.rows && res.rows.length > 0) {
  1180. res.rows = res.rows.map((item) => {
  1181. return {
  1182. ...item,
  1183. value: item.payName,
  1184. };
  1185. });
  1186. callback(res.rows);
  1187. } else {
  1188. callback([]);
  1189. }
  1190. });
  1191. };
  1192. const handleSubmit = async () => {
  1193. let status = await submit.value.handleSubmit(() => {});
  1194. if (status) {
  1195. // 合同交接单不可大于待采购数量
  1196. if (route.query.type == 1) {
  1197. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1198. const ele = formData.data.purchaseProductList[i];
  1199. for (let j = 0; j < ele.purchaseProductMountingsList.length; j++) {
  1200. const jele = ele.purchaseProductMountingsList[j];
  1201. if (j == 0) {
  1202. if (Number(jele.quantity) > Number(jele.oldQuantity)) {
  1203. ElMessage("采购数量不能大于待采购数量");
  1204. return false;
  1205. }
  1206. }
  1207. }
  1208. }
  1209. }
  1210. // if (
  1211. // formData.data.purchaseArrivalList &&
  1212. // formData.data.purchaseArrivalList.length > 0
  1213. // ) {
  1214. // for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1215. // let data = formData.data.purchaseArrivalList.filter(
  1216. // (item) =>
  1217. // item.productId === formData.data.purchaseProductList[i].productId
  1218. // );
  1219. // if (data && data.length > 0) {
  1220. // let quantity = 0;
  1221. // for (let j = 0; j < data.length; j++) {
  1222. // quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
  1223. // }
  1224. // if (quantity > formData.data.purchaseProductList[i].quantity) {
  1225. // ElMessage("到货数量不能大于采购数量");
  1226. // return false;
  1227. // }
  1228. // }
  1229. // }
  1230. // }
  1231. return true;
  1232. } else {
  1233. setTimeout(() => {
  1234. const errorDiv = document.getElementsByClassName("is-error");
  1235. errorDiv[0].scrollIntoView();
  1236. }, 0);
  1237. }
  1238. return status;
  1239. };
  1240. // 接收父组件的传值
  1241. const props = defineProps({
  1242. queryData: Object,
  1243. });
  1244. const getFormData = () => {
  1245. return proxy.deepClone(formData.data);
  1246. };
  1247. // 向父组件暴露
  1248. defineExpose({
  1249. getFormData,
  1250. handleSubmit,
  1251. });
  1252. const getAssociationData = (type, id) => {
  1253. if (type && id) {
  1254. if (type == 1) {
  1255. auxiliaryData.value[0].label = "关联销售订单";
  1256. proxy.post("/contract/detail", { id }).then((res) => {
  1257. contractData.value = [
  1258. {
  1259. contractCode: res.code,
  1260. claimTime: res.createTime,
  1261. },
  1262. ];
  1263. getAuxiliaryData();
  1264. });
  1265. } else if (type == 2) {
  1266. auxiliaryData.value[0].label = "关联样品单";
  1267. proxy.post("/sample/detail", { id }).then((res) => {
  1268. contractData.value = [
  1269. {
  1270. contractCode: res.code,
  1271. claimTime: res.createTime,
  1272. },
  1273. ];
  1274. getAuxiliaryData();
  1275. });
  1276. }
  1277. }
  1278. };
  1279. // 判断当前用户有无销售订单页面权限
  1280. const isHave = ref(false);
  1281. if (userInfo.permissions && userInfo.permissions.includes("contract")) {
  1282. isHave.value = true;
  1283. }
  1284. const handlePushRoute = (row) => {
  1285. proxy.$router.push({
  1286. name: "Contract",
  1287. query: {
  1288. code: row.value,
  1289. },
  1290. });
  1291. };
  1292. // 判断当前用户有无样品单页面权限
  1293. const isHaveOne = ref(false);
  1294. if (userInfo.permissions && userInfo.permissions.includes("sample")) {
  1295. isHaveOne.value = true;
  1296. }
  1297. const handlePushRouteOne = (row) => {
  1298. proxy.$router.push({
  1299. name: "Sample",
  1300. query: {
  1301. code: row.value,
  1302. },
  1303. });
  1304. };
  1305. onMounted(() => {
  1306. if (route.query && route.query.type && route.query.submitType === "10") {
  1307. getAssociationData(route.query.type, route.query.dataResourceId);
  1308. }
  1309. if (props.queryData.ids) {
  1310. proxy.post("/delivery/page", { ids: props.queryData.ids }).then((res) => {
  1311. formData.data.dataResource = props.queryData.type;
  1312. formData.data.dataResourceId = route.query.dataResourceId;
  1313. if (res.rows && res.rows.length > 0) {
  1314. formData.data.purchaseProductList = res.rows.map((item) => {
  1315. return {
  1316. productId: item.productId,
  1317. contractId: item.contractId,
  1318. productName: item.productName,
  1319. productModel: item.productModel,
  1320. quantity: item.expendQuantity,
  1321. oldQuantity: item.expendQuantity,
  1322. price: "",
  1323. amount: "",
  1324. remark: "",
  1325. json: "",
  1326. fileUrl: "",
  1327. dataResource: props.queryData.type,
  1328. dataResourceId: item.id,
  1329. purchaseProductMountingsList: [
  1330. {
  1331. productId: item.productId,
  1332. productType: 1,
  1333. productName: item.productName,
  1334. productModel: item.productModel,
  1335. quantity: item.expendQuantity,
  1336. oldQuantity: item.expendQuantity,
  1337. price: undefined,
  1338. amount: "",
  1339. remark: "",
  1340. json: "",
  1341. fileUrl: "",
  1342. activeName: true,
  1343. },
  1344. ],
  1345. fileList: [],
  1346. };
  1347. });
  1348. formData.data.purchaseArrivalList = res.rows.map((item) => {
  1349. return {
  1350. productCode: item.productCode,
  1351. productId: item.productId,
  1352. productName: item.productName,
  1353. arrivalTime: "",
  1354. quantity: undefined,
  1355. };
  1356. });
  1357. let fileIds = formData.data.purchaseProductList.map(
  1358. (item) => item.productId
  1359. );
  1360. proxy
  1361. .post("/fileInfo/getList", { businessIdList: fileIds })
  1362. .then((resFile) => {
  1363. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1364. if (
  1365. resFile[formData.data.purchaseProductList[i].productId] &&
  1366. resFile[formData.data.purchaseProductList[i].productId].length >
  1367. 0
  1368. ) {
  1369. formData.data.purchaseProductList[i].fileUrl =
  1370. resFile[
  1371. formData.data.purchaseProductList[i].productId
  1372. ][0].fileUrl;
  1373. formData.data.purchaseProductList[
  1374. i
  1375. ].purchaseProductMountingsList[0].fileUrl =
  1376. resFile[
  1377. formData.data.purchaseProductList[i].productId
  1378. ][0].fileUrl;
  1379. }
  1380. }
  1381. });
  1382. // 单价提示
  1383. changeProductPrice();
  1384. } else {
  1385. formData.data.purchaseProductList = [];
  1386. }
  1387. });
  1388. }
  1389. formOption.disabled = judgeStatus();
  1390. if (route.query && route.query.processType) {
  1391. let businessId = route.query.businessId;
  1392. proxy.post("/ehsdPurchase/detail", { id: businessId }).then((res) => {
  1393. // 退回回显
  1394. if (route.query.processType == 30) {
  1395. proxy
  1396. .post("/supplierInfo/page", { keyword: res.sellCorporationName })
  1397. .then((res) => {
  1398. supplierList.value = res.rows.map((item) => {
  1399. return {
  1400. ...item,
  1401. label: item.name,
  1402. value: item.id,
  1403. };
  1404. });
  1405. });
  1406. }
  1407. if (res.grossProfitInfoList && res.grossProfitInfoList.length > 0) {
  1408. $bus.emit("getGrossData", res.grossProfitInfoList);
  1409. }
  1410. res.purchaseProductList = res.ehsdPurchaseProductList || [];
  1411. if (!res.fileList) {
  1412. res.fileList = [];
  1413. }
  1414. res.countryId = res.sellCountryId;
  1415. res.provinceId = res.sellProvinceId;
  1416. res.cityId = res.sellCityId;
  1417. for (const key in res) {
  1418. formData.data[key] = res[key];
  1419. }
  1420. remarkEditor.value.changeHtml(formData.data.remark);
  1421. // 回显关联销售订单
  1422. if (route.query && route.query.submitType === "10") {
  1423. getAssociationData(
  1424. formData.data.dataResource,
  1425. formData.data.dataResourceId
  1426. );
  1427. }
  1428. proxy
  1429. .post("/fileInfo/getList", {
  1430. businessIdList: [businessId],
  1431. })
  1432. .then((fileObj) => {
  1433. if (fileObj[businessId]) {
  1434. formData.data.fileList = fileObj[businessId]
  1435. .filter((x) => x.businessType === "1")
  1436. .map((x) => ({ raw: x, name: x.fileName, url: x.fileUrl }));
  1437. formData.data.packageFileList = fileObj[businessId]
  1438. .filter((x) => x.businessType === "2")
  1439. .map((x) => ({ raw: x, name: x.fileName, url: x.fileUrl }));
  1440. }
  1441. });
  1442. if (
  1443. formData.data.purchaseProductList &&
  1444. formData.data.purchaseProductList.length > 0
  1445. ) {
  1446. let ids = formData.data.purchaseProductList.map((x) => x.productId);
  1447. getAuxiliaryData(formData.data.sellCorporationId, ids);
  1448. proxy
  1449. .post("/fileInfo/getList", {
  1450. businessIdList: ids,
  1451. })
  1452. .then((fileObj) => {
  1453. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1454. const e = formData.data.purchaseProductList[i];
  1455. e.activeName = true;
  1456. for (const key in fileObj) {
  1457. if (e.productId === key) {
  1458. e.fileList = fileObj[key] || [];
  1459. if (e.fileList && e.fileList.length > 0) {
  1460. e.fileUrl = e.fileList[0].fileUrl;
  1461. }
  1462. }
  1463. }
  1464. }
  1465. });
  1466. changeProductPrice();
  1467. }
  1468. if (formData.data.countryId) {
  1469. getCityData(formData.data.countryId, "20");
  1470. }
  1471. if (formData.data.provinceId) {
  1472. getCityData(formData.data.provinceId, "30");
  1473. }
  1474. });
  1475. }
  1476. });
  1477. const clickSplit = (item) => {
  1478. formData.data.purchaseArrivalList.push({
  1479. productCode: item.code,
  1480. productId: item.productId,
  1481. productName: item.productName,
  1482. arrivalTime: "",
  1483. remark: "",
  1484. quantity: undefined,
  1485. });
  1486. };
  1487. const clickDelete = (index) => {
  1488. formData.data.purchaseArrivalList.splice(index, 1);
  1489. };
  1490. const updateContent = (val) => {
  1491. formData.data.remark = val;
  1492. };
  1493. const remarkEditor = ref(null);
  1494. const changeContractTemplate = (val) => {
  1495. if (val) {
  1496. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  1497. remarkEditor.value.changeHtml(res.templateContent);
  1498. });
  1499. }
  1500. };
  1501. const productRow = reactive({
  1502. data: {
  1503. productName: "",
  1504. remark: "",
  1505. },
  1506. });
  1507. const productIndex = ref(0);
  1508. const openHandover = ref(false);
  1509. const fileList = ref([]);
  1510. const uploadData = ref({});
  1511. const formHandoverConfig = computed(() => {
  1512. return [
  1513. {
  1514. type: "title",
  1515. title: "产品信息",
  1516. label: "",
  1517. },
  1518. {
  1519. type: "input",
  1520. prop: "productName",
  1521. label: "产品名称",
  1522. itemType: "text",
  1523. disabled: true,
  1524. },
  1525. {
  1526. type: "input",
  1527. prop: "productModel",
  1528. label: "规格型号",
  1529. itemType: "text",
  1530. disabled: true,
  1531. },
  1532. {
  1533. type: "slot",
  1534. prop: "file",
  1535. slotName: "file",
  1536. label: "上传附件",
  1537. },
  1538. {
  1539. type: "slot",
  1540. slotName: "remark",
  1541. label: "备注",
  1542. },
  1543. ];
  1544. });
  1545. const handleHandover = (row, index) => {
  1546. productRow.data = {
  1547. productName: row.productName,
  1548. remark: row.remark,
  1549. };
  1550. if (row.fileList && row.fileList.length > 0) {
  1551. fileList.value = row.fileList.map((item) => {
  1552. return {
  1553. raw: item,
  1554. name: item.fileName,
  1555. url: item.fileUrl,
  1556. };
  1557. });
  1558. } else {
  1559. fileList.value = [];
  1560. }
  1561. productIndex.value = index;
  1562. openHandover.value = true;
  1563. };
  1564. const handleMaterial = (index) => {
  1565. productIndex.value = index;
  1566. alreadySelectData.value = formData.data.purchaseProductList[
  1567. index
  1568. ].purchaseProductMountingsList.filter((x) => x.productType == 2);
  1569. openMaterialCompany.value = true;
  1570. };
  1571. const uploadFile = async (file) => {
  1572. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1573. uploadData.value = res.uploadBody;
  1574. file.id = res.id;
  1575. file.fileName = res.fileName;
  1576. file.fileUrl = res.fileUrl;
  1577. file.uploadState = true;
  1578. return true;
  1579. };
  1580. const handleSuccess = (any, UploadFile) => {
  1581. UploadFile.raw.uploadState = false;
  1582. };
  1583. const onPreviewFile = (file) => {
  1584. window.open(file.raw.fileUrl, "_blank");
  1585. };
  1586. const updateHandover = (val) => {
  1587. productRow.data.remark = val;
  1588. };
  1589. const submitHandoverForm = () => {
  1590. if (fileList.value && fileList.value.length > 0) {
  1591. for (let i = 0; i < fileList.value.length; i++) {
  1592. if (fileList.value[i].raw.uploadState) {
  1593. ElMessage("文件上传中,请稍后提交");
  1594. return;
  1595. }
  1596. }
  1597. formData.data.purchaseProductList[productIndex.value].fileList =
  1598. fileList.value.map((item) => {
  1599. return {
  1600. id: item.raw.id,
  1601. fileName: item.raw.fileName,
  1602. fileUrl: item.raw.fileUrl,
  1603. uploadState: item.raw.uploadState,
  1604. };
  1605. });
  1606. } else {
  1607. formData.data.purchaseProductList[productIndex.value].fileList = [];
  1608. }
  1609. formData.data.purchaseProductList[productIndex.value].remark =
  1610. productRow.data.remark;
  1611. openHandover.value = false;
  1612. };
  1613. const selectMaterial = (goods) => {
  1614. if (goods && goods.id) {
  1615. let data = formData.data.purchaseProductList[
  1616. productIndex.value
  1617. ].purchaseProductMountingsList.filter(
  1618. (item) => item.productId === goods.id
  1619. );
  1620. // if (data && data.length > 0) {
  1621. // return ElMessage("该物料已添加");
  1622. // }
  1623. let fileUrl = "";
  1624. if (goods.fileList && goods.fileList.length > 0) {
  1625. fileUrl = goods.fileList[0].fileUrl;
  1626. }
  1627. formData.data.purchaseProductList[
  1628. productIndex.value
  1629. ].purchaseProductMountingsList.push({
  1630. productId: goods.id,
  1631. productType: 2,
  1632. productName: goods.name,
  1633. productModel: goods.spec,
  1634. quantity: undefined,
  1635. price: undefined,
  1636. amount: "",
  1637. remark: "",
  1638. json: "",
  1639. fileUrl: fileUrl,
  1640. activeName: true,
  1641. });
  1642. changeProductPrice();
  1643. ElMessage({
  1644. message: "添加成功!",
  1645. type: "success",
  1646. });
  1647. } else {
  1648. return ElMessage("选择错误");
  1649. }
  1650. };
  1651. const getStyle = (text) => {
  1652. if (text) {
  1653. return text.replace(/\n|\r\n/g, "<br>");
  1654. } else {
  1655. return "";
  1656. }
  1657. };
  1658. const emit = defineEmits(["auxiliaryChange"]);
  1659. let auxiliaryData = ref([
  1660. {
  1661. label: "关联销售订单",
  1662. data: [],
  1663. },
  1664. {
  1665. label: "供应商最近采购",
  1666. data: [],
  1667. },
  1668. {
  1669. label: "产品价格",
  1670. data: [],
  1671. },
  1672. ]);
  1673. const auxiliaryChange = (data) => {
  1674. emit("auxiliaryChange", data);
  1675. };
  1676. const contractData = ref([]);
  1677. const getAuxiliaryData = (supplyId, productIdList) => {
  1678. if (supplyId && productIdList.length > 0) {
  1679. proxy
  1680. .post("/subscribe/decisionAid", {
  1681. supplyId: supplyId,
  1682. productIdList: productIdList,
  1683. })
  1684. .then((res) => {
  1685. // 供应商最近采购
  1686. const recentlyArr = [
  1687. {
  1688. label: "合同编号",
  1689. value: "",
  1690. fn:
  1691. route.query.type == 2
  1692. ? isHaveOne
  1693. ? handlePushRouteOne
  1694. : () => {}
  1695. : isHave
  1696. ? handlePushRoute
  1697. : () => {},
  1698. num: 1,
  1699. },
  1700. {
  1701. label: "下单日期",
  1702. value: "",
  1703. num: 1,
  1704. },
  1705. {
  1706. label: "合同金额",
  1707. value: "",
  1708. num: 1,
  1709. },
  1710. ];
  1711. auxiliaryData.value[1].data = res.purchaseList.map((x, index) => {
  1712. return recentlyArr.map((y, sonIndex) => {
  1713. let obj = { ...y };
  1714. let value = "";
  1715. if (sonIndex === 0) {
  1716. value = x.code;
  1717. } else if (sonIndex === 1) {
  1718. value = x.createTime;
  1719. } else {
  1720. value = x.currency + " " + proxy.moneyFormat(x.amount, 2);
  1721. }
  1722. obj.value = value;
  1723. return obj;
  1724. });
  1725. });
  1726. // 产品价格
  1727. const arrConfig = [
  1728. {
  1729. label: "产品名称",
  1730. value: "",
  1731. num: 1,
  1732. },
  1733. {
  1734. label: "最近价格",
  1735. value: "",
  1736. num: 1,
  1737. },
  1738. {
  1739. label: "历史最高",
  1740. value: "",
  1741. num: 1,
  1742. },
  1743. {
  1744. label: "历史最低",
  1745. value: "",
  1746. num: 1,
  1747. },
  1748. ];
  1749. auxiliaryData.value[2].data = res.productPriceList.map((x, index) => {
  1750. return arrConfig.map((y, sonIndex) => {
  1751. let obj = { ...y };
  1752. let value = "";
  1753. if (sonIndex === 0) {
  1754. value = x.name;
  1755. } else if (sonIndex === 1) {
  1756. value = x.lastPrice;
  1757. } else if (sonIndex === 2) {
  1758. value = x.maxPrice;
  1759. } else {
  1760. value = x.minPrice;
  1761. }
  1762. obj.value = value;
  1763. return obj;
  1764. });
  1765. });
  1766. auxiliaryChange(auxiliaryData.value);
  1767. });
  1768. } else {
  1769. let arrConfig = [
  1770. {
  1771. label: "合同编号",
  1772. value: "",
  1773. fn:
  1774. route.query.type == 2
  1775. ? isHaveOne
  1776. ? handlePushRouteOne
  1777. : () => {}
  1778. : isHave
  1779. ? handlePushRoute
  1780. : () => {},
  1781. num: 1,
  1782. },
  1783. {
  1784. label: "下单日期",
  1785. value: "",
  1786. num: 1,
  1787. },
  1788. ];
  1789. auxiliaryData.value[0].data = contractData.value.map((x, index) => {
  1790. return arrConfig.map((y, sonIndex) => {
  1791. let obj = { ...y };
  1792. let value = "";
  1793. if (sonIndex === 0) {
  1794. value = contractData.value[index].contractCode;
  1795. } else if (sonIndex === 1) {
  1796. value = contractData.value[index].claimTime;
  1797. }
  1798. obj.value = value;
  1799. return obj;
  1800. });
  1801. });
  1802. auxiliaryChange(auxiliaryData.value);
  1803. }
  1804. };
  1805. const getHtmlVal = (val) => {
  1806. if (val) {
  1807. return val.replace(/<p>/g, "<div>").replace(/<\/p>/g, "</div>");
  1808. }
  1809. return "";
  1810. };
  1811. const loadingSearch = ref(false);
  1812. const remoteMethod = (keyword) => {
  1813. if (keyword && typeof keyword === "string") {
  1814. loadingSearch.value = true;
  1815. proxy.post("/supplierInfo/page", { keyword }).then((res) => {
  1816. supplierList.value = res.rows.map((item) => {
  1817. return {
  1818. ...item,
  1819. label: item.name,
  1820. value: item.id,
  1821. };
  1822. });
  1823. loadingSearch.value = false;
  1824. });
  1825. }
  1826. return;
  1827. };
  1828. const clickCopy = () => {
  1829. copyContract.value = true;
  1830. };
  1831. const selectPurchase = (businessId) => {
  1832. if (businessId) {
  1833. proxy.post("/ehsdPurchase/detail", { id: businessId }).then((res) => {
  1834. res.purchaseProductList = res.ehsdPurchaseProductList || [];
  1835. if (!res.fileList) {
  1836. res.fileList = [];
  1837. }
  1838. res.countryId = res.sellCountryId;
  1839. res.provinceId = res.sellProvinceId;
  1840. res.cityId = res.sellCityId;
  1841. for (let key in res) {
  1842. if (
  1843. ![
  1844. "purchaseProductList",
  1845. "ehsdPurchaseProductList",
  1846. "purchaseArrivalList",
  1847. ].includes(key)
  1848. ) {
  1849. formData.data[key] = res[key];
  1850. }
  1851. }
  1852. remarkEditor.value.changeHtml(formData.data.remark);
  1853. // 回显关联销售订单
  1854. if (route.query && route.query.submitType === "10") {
  1855. getAssociationData(
  1856. formData.data.dataResource,
  1857. formData.data.dataResourceId
  1858. );
  1859. }
  1860. proxy
  1861. .post("/fileInfo/getList", {
  1862. businessIdList: [businessId],
  1863. })
  1864. .then((fileObj) => {
  1865. if (fileObj[businessId]) {
  1866. formData.data.fileList = fileObj[businessId]
  1867. .filter((x) => x.businessType === "1")
  1868. .map((x) => ({ raw: x, name: x.fileName, url: x.fileUrl }));
  1869. formData.data.packageFileList = fileObj[businessId]
  1870. .filter((x) => x.businessType === "2")
  1871. .map((x) => ({ raw: x, name: x.fileName, url: x.fileUrl }));
  1872. }
  1873. });
  1874. if (
  1875. formData.data.purchaseProductList &&
  1876. formData.data.purchaseProductList.length > 0
  1877. ) {
  1878. let ids = formData.data.purchaseProductList.map((x) => x.productId);
  1879. getAuxiliaryData(formData.data.sellCorporationId, ids);
  1880. proxy
  1881. .post("/fileInfo/getList", {
  1882. businessIdList: ids,
  1883. })
  1884. .then((fileObj) => {
  1885. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1886. const e = formData.data.purchaseProductList[i];
  1887. e.activeName = true;
  1888. for (const key in fileObj) {
  1889. if (e.productId === key) {
  1890. e.fileList = fileObj[key] || [];
  1891. if (e.fileList && e.fileList.length > 0) {
  1892. e.fileUrl = e.fileList[0].fileUrl;
  1893. }
  1894. }
  1895. }
  1896. }
  1897. });
  1898. changeProductPrice();
  1899. }
  1900. if (formData.data.countryId) {
  1901. getCityData(formData.data.countryId, "20");
  1902. }
  1903. if (formData.data.provinceId) {
  1904. getCityData(formData.data.provinceId, "30");
  1905. }
  1906. });
  1907. copyContract.value = false;
  1908. ElMessage({
  1909. message: "选择成功!",
  1910. type: "success",
  1911. });
  1912. }
  1913. };
  1914. const optionTwo = reactive({
  1915. data: {
  1916. tooltip: {
  1917. trigger: "axis",
  1918. },
  1919. // legend: {
  1920. // data: ["价格"],
  1921. // },
  1922. grid: {
  1923. left: "3%",
  1924. right: "4%",
  1925. top: "10%",
  1926. bottom: "3%",
  1927. containLabel: true,
  1928. },
  1929. // toolbox: {
  1930. // feature: {
  1931. // saveAsImage: {},
  1932. // },
  1933. // },
  1934. xAxis: {
  1935. type: "category",
  1936. boundaryGap: false,
  1937. data: [],
  1938. },
  1939. yAxis: {
  1940. type: "value",
  1941. },
  1942. series: [
  1943. {
  1944. name: "价格",
  1945. type: "line",
  1946. data: [],
  1947. },
  1948. ],
  1949. },
  1950. });
  1951. const showEcharts = (row, index) => {
  1952. let myChart = null;
  1953. myChart = echarts.init(document.getElementById(row.productId + index));
  1954. window.addEventListener("resize", () => {
  1955. myChart.resize();
  1956. });
  1957. if (
  1958. row.purchaseProductPriceListOne &&
  1959. row.purchaseProductPriceListOne.length > 0
  1960. ) {
  1961. optionTwo.data.xAxis.data = row.purchaseProductPriceListOne.map((item) => {
  1962. return item.createTime.slice(0, 10);
  1963. });
  1964. optionTwo.data.series[0].data = row.purchaseProductPriceListOne.map(
  1965. (item) => {
  1966. return item.price;
  1967. }
  1968. );
  1969. } else {
  1970. optionTwo.data.xAxis.data = [];
  1971. optionTwo.data.series[0].data = [];
  1972. }
  1973. myChart.setOption(optionTwo.data);
  1974. myChart.resize();
  1975. };
  1976. </script>
  1977. <style lang="scss" scoped>
  1978. ::v-deep(.el-input-number .el-input__inner) {
  1979. text-align: left;
  1980. }
  1981. .pic {
  1982. object-fit: contain;
  1983. width: 50px;
  1984. height: 50px;
  1985. cursor: pointer;
  1986. vertical-align: middle;
  1987. }
  1988. .shrinkPadding {
  1989. padding-right: 0 !important;
  1990. }
  1991. .hideCollapse {
  1992. margin-top: -28px;
  1993. border: 0 !important;
  1994. }
  1995. ::v-deep(.el-collapse-item__arrow) {
  1996. display: none !important;
  1997. }
  1998. ::v-deep(.el-collapse-item__wrap) {
  1999. border: 0 !important;
  2000. }
  2001. ::v-deep(.el-collapse-item__header) {
  2002. border: 0 !important;
  2003. }
  2004. ::v-deep(.el-collapse-item__content) {
  2005. padding-bottom: 8px !important;
  2006. }
  2007. .pic {
  2008. object-fit: contain;
  2009. width: 50px;
  2010. height: 50px;
  2011. cursor: pointer;
  2012. vertical-align: middle;
  2013. }
  2014. ::v-deep(.removePadding) {
  2015. .el-form-item {
  2016. padding-right: 0 !important;
  2017. }
  2018. }
  2019. .img {
  2020. object-fit: contain;
  2021. width: 16px;
  2022. height: 16px;
  2023. vertical-align: middle;
  2024. }
  2025. </style>