ContractChange.vue 73 KB

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