Contract.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  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%" disabled>
  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"> </el-input>
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. <el-row style="margin-top: 20px; width: 100%">
  36. <el-col :span="8">
  37. <el-form-item label="联系人" prop="sellContactName">
  38. <el-input v-model="formData.data.sellContactName" placeholder="请输入联系人" />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="16">
  42. <el-form-item label=" " prop="sellContactNumber">
  43. <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </div>
  48. </template>
  49. <template #buyer>
  50. <div style="width: 100%">
  51. <div style="width: 100%">
  52. <el-form-item prop="buyCorporationId">
  53. <el-select v-model="formData.data.buyCorporationId" style="width: 100%" @change="changeCustomer">
  54. <el-option v-for="item in customerList" :key="item.value" :label="item.label" :value="item.value" />
  55. </el-select>
  56. </el-form-item>
  57. <el-row style="margin-top: 20px; width: 100%">
  58. <el-col :span="6">
  59. <el-form-item label="地址" prop="countryId">
  60. <el-select v-model="formData.data.countryId" placeholder="国家" filterable @change="(val) => getCityData(val, '20', true)">
  61. <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id"> </el-option>
  62. </el-select>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="6">
  66. <el-form-item label=" " prop="provinceName">
  67. <selectCity
  68. placeholder="省/洲"
  69. @change="(val) => getCityData(val, '30', true)"
  70. addressId="provinceId"
  71. addressName="provinceName"
  72. v-model="formData.data"
  73. :data="provinceData">
  74. </selectCity>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="6">
  78. <el-form-item label=" " prop="cityName">
  79. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData"> </selectCity>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="6">
  83. <el-form-item label=" " prop="buyPostalCode">
  84. <el-input v-model="formData.data.buyPostalCode" placeholder="请输入邮编" />
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <el-row style="margin-top: 20px; width: 100%">
  89. <el-col :span="24">
  90. <el-form-item prop="buyAddress">
  91. <el-input v-model="formData.data.buyAddress" type="textarea"> </el-input>
  92. </el-form-item>
  93. </el-col>
  94. </el-row>
  95. <el-row style="margin-top: 20px; width: 100%">
  96. <el-col :span="8">
  97. <el-form-item label="联系人" prop="buyContactName">
  98. <el-autocomplete
  99. v-model="formData.data.buyContactName"
  100. :fetch-suggestions="querySearchPerson"
  101. clearable
  102. class="inline-input w-50"
  103. placeholder="请输入联系人"
  104. @select="handlePerson">
  105. </el-autocomplete>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="16">
  109. <el-form-item label=" " prop="buyContactNumber">
  110. <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. </div>
  115. </div>
  116. </template>
  117. <template #payment>
  118. <div style="width: 100%">
  119. <el-row style="margin-top: 20px; width: 100%">
  120. <el-col :span="6">
  121. <el-form-item label="币种" prop="currency">
  122. <el-select v-model="formData.data.currency" placeholder="请选择币种" style="width: 100%">
  123. <el-option v-for="item in accountCurrency" :key="item.value" :label="item.label" :value="item.value" />
  124. </el-select>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="6">
  128. <el-form-item label="付款方式" prop="paymentMethod">
  129. <el-select v-model="formData.data.paymentMethod" placeholder="请选择付款方式" style="width: 100%">
  130. <el-option v-for="item in fundsPaymentMethod" :key="item.value" :label="item.label" :value="item.value" />
  131. </el-select>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="6">
  135. <el-form-item label="预付比例 (%)" prop="advanceRatio">
  136. <el-input-number
  137. onmousewheel="return false;"
  138. v-model="formData.data.advanceRatio"
  139. placeholder="请输入预付比例"
  140. style="width: 100%"
  141. :precision="2"
  142. :controls="false"
  143. :min="0"
  144. :max="100" />
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. <el-row style="margin-top: 20px; width: 100%">
  149. <el-col :span="18">
  150. <el-form-item label="付款条件" prop="remark">
  151. <el-input v-model="formData.data.remark" :rows="2" type="textarea" placeholder="请输入付款条件" />
  152. </el-form-item>
  153. </el-col>
  154. </el-row>
  155. <el-row style="margin-top: 20px; width: 100%">
  156. <el-col :span="9">
  157. <el-form-item label="收款账号" prop="shroffAccountId">
  158. <el-select v-model="formData.data.shroffAccountId" placeholder="请选择收款账号" style="width: 100%" @change="changeShroffAccount">
  159. <el-option v-for="item in accountList" :key="item.value" :label="item.label" :value="item.value" />
  160. </el-select>
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="9">
  164. <el-form-item label=" ">
  165. <el-button type="primary" @click="changeActiveName" text>
  166. <span v-if="activeName == '1'">收起</span>
  167. <span v-else>展开</span>
  168. </el-button>
  169. </el-form-item>
  170. </el-col>
  171. </el-row>
  172. <div style="width: 100%; margin-top: 34px">
  173. <el-collapse v-model="activeName" class="hideCollapse" accordion>
  174. <el-collapse-item title="" name="1">
  175. <el-row style="width: 100%">
  176. <el-col :span="9">
  177. <el-form-item label="Beneficiary Name" prop="beneficiaryName">
  178. <el-input v-model="formData.data.beneficiaryName" placeholder="请输入Beneficiary Name" />
  179. </el-form-item>
  180. <div style="height: 20px"></div>
  181. <el-form-item label="Beneficiary Bank" prop="beneficiaryBank">
  182. <el-input v-model="formData.data.beneficiaryBank" placeholder="请输入Beneficiary Bank" />
  183. </el-form-item>
  184. <div style="height: 20px"></div>
  185. <el-form-item label="Beneficiary Bank Address" prop="beneficiaryBankAddress">
  186. <el-input v-model="formData.data.beneficiaryBankAddress" placeholder="请输入Beneficiary Bank Address" />
  187. </el-form-item>
  188. </el-col>
  189. <el-col :span="9">
  190. <el-form-item label="Beneficiary Account Number" prop="beneficiaryAccountNumber">
  191. <el-input v-model="formData.data.beneficiaryAccountNumber" placeholder="请输入Beneficiary Account Number" />
  192. </el-form-item>
  193. <div style="height: 20px"></div>
  194. <el-form-item label="Swift Code" prop="swiftCode">
  195. <el-input v-model="formData.data.swiftCode" placeholder="请输入Swift Code" />
  196. </el-form-item>
  197. <div style="height: 20px"></div>
  198. <el-form-item label="Beneficiary Address" prop="beneficiaryAddress">
  199. <el-input v-model="formData.data.beneficiaryAddress" placeholder="请输入Beneficiary Address" />
  200. </el-form-item>
  201. </el-col>
  202. </el-row>
  203. </el-collapse-item>
  204. </el-collapse>
  205. </div>
  206. </div>
  207. </template>
  208. <template #delivery>
  209. <div style="width: 100%">
  210. <el-row style="margin-top: 20px; width: 100%">
  211. <el-col :span="6">
  212. <el-form-item label="报价有效期 (天)" prop="effective">
  213. <el-input-number
  214. onmousewheel="return false;"
  215. v-model="formData.data.effective"
  216. placeholder="请输入有效期"
  217. style="width: 100%"
  218. :precision="0"
  219. :controls="false"
  220. :min="0" />
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="6">
  224. <el-form-item label="交货期限" prop="deliveryTime">
  225. <el-date-picker v-model="formData.data.deliveryTime" type="date" placeholder="请选择交货期限" value-format="YYYY-MM-DD" />
  226. </el-form-item>
  227. </el-col>
  228. <el-col :span="6">
  229. <el-form-item label="运输方式" prop="transportMethod">
  230. <el-select v-model="formData.data.transportMethod" placeholder="请选择运输方式" style="width: 100%">
  231. <el-option v-for="item in shippingMethod" :key="item.value" :label="item.label" :value="item.value" />
  232. </el-select>
  233. </el-form-item>
  234. </el-col>
  235. <el-col :span="6">
  236. <el-form-item label="运输说明" prop="transportRemark">
  237. <el-input v-model="formData.data.transportRemark" placeholder="请输入运输说明" />
  238. </el-form-item>
  239. </el-col>
  240. </el-row>
  241. </div>
  242. </template>
  243. <template #commodity>
  244. <div style="width: 100%">
  245. <el-button type="primary" @click="openProductCompany = true" plain>标准产品库</el-button>
  246. <el-button type="primary" @click="clickCustomerProduct()" plain>客户产品库</el-button>
  247. <el-table :data="formData.data.contractProductList" style="width: 100%; margin-top: 16px">
  248. <el-table-column label="商品图片" width="80">
  249. <template #default="{ row }">
  250. <div v-if="row.productId">
  251. <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  252. </div>
  253. <div v-else></div>
  254. </template>
  255. </el-table-column>
  256. <el-table-column label="商品名称" min-width="180">
  257. <template #default="{ row, $index }">
  258. <div style="width: 100%">
  259. <el-form-item
  260. :prop="'contractProductList.' + $index + '.productName'"
  261. :rules="rules.productName"
  262. :inline-message="true"
  263. class="shrinkPadding">
  264. <el-input v-model="row.productName" placeholder="请输入商品名称" />
  265. </el-form-item>
  266. </div>
  267. </template>
  268. </el-table-column>
  269. <el-table-column label="尺寸 cm*cm*cm" width="140">
  270. <template #default="{ row, $index }">
  271. <div style="width: 100%">
  272. <el-form-item
  273. :prop="'contractProductList.' + $index + '.productModel'"
  274. :rules="rules.productModel"
  275. :inline-message="true"
  276. class="shrinkPadding">
  277. <el-input v-model="row.productModel" placeholder="请输入" />
  278. </el-form-item>
  279. </div>
  280. </template>
  281. </el-table-column>
  282. <el-table-column label="数量" width="130">
  283. <template #default="{ row, $index }">
  284. <div style="width: 100%">
  285. <el-form-item :prop="'contractProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" class="shrinkPadding">
  286. <el-input-number
  287. onmousewheel="return false;"
  288. v-model="row.quantity"
  289. placeholder="请输入"
  290. style="width: 100%"
  291. :precision="0"
  292. :controls="false"
  293. :min="0"
  294. @change="calculationAmount()" />
  295. </el-form-item>
  296. </div>
  297. </template>
  298. </el-table-column>
  299. <el-table-column label="单价" width="140">
  300. <template #default="{ row, $index }">
  301. <div style="width: 100%">
  302. <el-form-item :prop="'contractProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true" class="shrinkPadding">
  303. <el-input-number
  304. onmousewheel="return false;"
  305. v-model="row.price"
  306. placeholder="请输入"
  307. style="width: 100%"
  308. :precision="2"
  309. :controls="false"
  310. :min="0"
  311. @change="calculationAmount()" />
  312. </el-form-item>
  313. </div>
  314. </template>
  315. </el-table-column>
  316. <el-table-column label="贸易方式" width="140">
  317. <template #default="{ row, $index }">
  318. <div style="width: 100%">
  319. <el-form-item
  320. :prop="'contractProductList.' + $index + '.tradeMethods'"
  321. :rules="rules.tradeMethods"
  322. :inline-message="true"
  323. class="shrinkPadding">
  324. <el-select v-model="row.tradeMethods" placeholder="请选择" style="width: 100%">
  325. <el-option v-for="item in tradeMethods" :key="item.value" :label="item.label" :value="item.value" />
  326. </el-select>
  327. </el-form-item>
  328. </div>
  329. </template>
  330. </el-table-column>
  331. <el-table-column label="包装方式" width="180">
  332. <template #default="{ row, $index }">
  333. <div style="width: 100%">
  334. <el-form-item :prop="'contractProductList.' + $index + '.packMethod'" :rules="rules.packMethod" :inline-message="true" class="shrinkPadding">
  335. <el-input v-model="row.packMethod" placeholder="请输入" />
  336. </el-form-item>
  337. </div>
  338. </template>
  339. </el-table-column>
  340. <el-table-column prop="amount" :label="'金额 ( ' + formData.data.currency + ' )'" width="130" />
  341. <el-table-column label="操作" width="60" align="center" fixed="right">
  342. <template #default="{ row, $index }">
  343. <el-button type="primary" link @click="handleRemove($index, row)">删除</el-button>
  344. </template>
  345. </el-table-column>
  346. </el-table>
  347. </div>
  348. </template>
  349. <template #file>
  350. <div style="width: 100%">
  351. <el-upload
  352. v-model:fileList="formData.data.fileList"
  353. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  354. :data="uploadData"
  355. multiple
  356. :before-upload="uploadFile"
  357. :on-success="handleSuccess"
  358. :on-preview="onPreviewFile">
  359. <el-button type="primary" plain>选择</el-button>
  360. </el-upload>
  361. </div>
  362. </template>
  363. <template #indication>
  364. <div style="width: 100%">
  365. <el-upload
  366. v-model:fileList="formData.data.packageFileList"
  367. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  368. :data="indicationUploadData"
  369. multiple
  370. :before-upload="indicationUploadFile"
  371. :on-success="handleSuccess"
  372. :on-preview="onPreviewFile">
  373. <el-button type="primary" plain>选择</el-button>
  374. </el-upload>
  375. </div>
  376. </template>
  377. <template #otherCharge>
  378. <div style="width: 100%">
  379. <el-button type="primary" @click="clickAdd()">添加行</el-button>
  380. <el-table :data="formData.data.contractProjectList" style="width: 100%; margin-top: 16px">
  381. <el-table-column label="收费项目" width="220">
  382. <template #default="{ row, $index }">
  383. <div style="width: 100%">
  384. <el-form-item :prop="'contractProjectList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true">
  385. <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50" placeholder="请输入收费项目" />
  386. </el-form-item>
  387. </div>
  388. </template>
  389. </el-table-column>
  390. <el-table-column label="备注">
  391. <template #default="{ row, $index }">
  392. <div style="width: 100%">
  393. <el-form-item :prop="'contractProjectList.' + $index + '.remark'">
  394. <el-input v-model="row.remark" placeholder="请输入备注" />
  395. </el-form-item>
  396. </div>
  397. </template>
  398. </el-table-column>
  399. <el-table-column :label="'金额 ( ' + formData.data.currency + ' )'" width="130">
  400. <template #default="{ row, $index }">
  401. <div style="width: 100%">
  402. <el-form-item :prop="'contractProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true" class="shrinkPadding">
  403. <el-input-number
  404. onmousewheel="return false;"
  405. v-model="row.amount"
  406. placeholder="请输入金额"
  407. style="width: 100%"
  408. :precision="2"
  409. :controls="false"
  410. :min="0"
  411. @change="totalAmount()" />
  412. </el-form-item>
  413. </div>
  414. </template>
  415. </el-table-column>
  416. <el-table-column label="操作" width="60" align="center" fixed="right">
  417. <template #default="{ $index }">
  418. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  419. </template>
  420. </el-table-column>
  421. </el-table>
  422. </div>
  423. </template>
  424. <template #offerMoney>
  425. <div style="width: 100%; display: flex">
  426. <div style="width: calc(100% - 190px)"></div>
  427. <div style="width: 130px; padding: 0 12px">
  428. <el-form-item label="合同总金额" prop="amount" class="shrinkPadding">
  429. <el-input v-model="formData.data.amount" placeholder="合同总金额" disabled />
  430. </el-form-item>
  431. </div>
  432. </div>
  433. </template>
  434. <template #shipment>
  435. <div style="width: 100%">
  436. <el-table :data="formData.data.contractShipmentList" style="width: 100%; margin-top: 16px">
  437. <el-table-column prop="code" label="商品编码" width="120" />
  438. <el-table-column prop="productName" label="商品名称" />
  439. <el-table-column label="出货日期" width="220">
  440. <template #default="{ row, $index }">
  441. <div style="width: 100%">
  442. <el-form-item :prop="'contractShipmentList.' + $index + '.shipmentTime'" :rules="rules.shipmentTime" :inline-message="true">
  443. <el-date-picker v-model="row.shipmentTime" type="date" placeholder="请选择出货日期" value-format="YYYY-MM-DD" />
  444. </el-form-item>
  445. </div>
  446. </template>
  447. </el-table-column>
  448. <el-table-column label="数量" width="160">
  449. <template #default="{ row, $index }">
  450. <div style="width: 100%">
  451. <el-form-item :prop="'contractShipmentList.' + $index + '.quantity'" :inline-message="true">
  452. <el-input-number
  453. onmousewheel="return false;"
  454. v-model="row.quantity"
  455. placeholder="请输入数量"
  456. style="width: 100%"
  457. :precision="0"
  458. :controls="false"
  459. :min="0"
  460. @change="calculationAmount()" />
  461. </el-form-item>
  462. </div>
  463. </template>
  464. </el-table-column>
  465. <el-table-column align="center" label="操作" width="120" fixed="right">
  466. <template #default="{ row, $index }">
  467. <el-button type="primary" link @click="clickSplit(row)">拆分</el-button>
  468. <el-button type="primary" link @click="clickDelete($index)">删除</el-button>
  469. </template>
  470. </el-table-column>
  471. </el-table>
  472. </div>
  473. </template>
  474. </byForm>
  475. <el-dialog v-if="openProductCompany" v-model="openProductCompany" title="公司产品库" width="90%" append-to-body>
  476. <CompanyProduct :selectStatus="true" @selectProduct="selectProduct"></CompanyProduct>
  477. </el-dialog>
  478. <el-dialog v-if="openProductCustomer" v-model="openProductCustomer" title="客户产品库" width="90%" append-to-body>
  479. <CustomerProduct :selectStatus="true" :buyCorporationId="formData.data.buyCorporationId" @selectProduct="selectProduct"></CustomerProduct>
  480. </el-dialog>
  481. </div>
  482. </template>
  483. <script setup>
  484. import byForm from "@/components/byForm/index";
  485. import CompanyProduct from "@/views/EHSD/productLibrary/companyProduct/index";
  486. import CustomerProduct from "@/views/EHSD/productLibrary/customerProduct/index";
  487. import { ElMessage } from "element-plus";
  488. import selectCity from "@/components/selectCity/index.vue";
  489. const { proxy } = getCurrentInstance();
  490. const innerMethod = ref([]);
  491. const outsideMethod = ref([]);
  492. const accountCurrency = ref([]);
  493. const fundsPaymentMethod = ref([]);
  494. const tradeMethods = ref([]);
  495. const shippingMethod = ref([]);
  496. const templateList = ref([]);
  497. const corporationList = ref([]);
  498. const customerList = ref([]);
  499. const accountList = ref([]);
  500. const countryData = ref([]);
  501. const provinceData = ref([]);
  502. const cityData = ref([]);
  503. const customerUserList = ref([]);
  504. const openProductCompany = ref(false);
  505. const openProductCustomer = ref(false);
  506. const activeName = ref("");
  507. const formData = reactive({
  508. data: {
  509. currency: "¥",
  510. amount: undefined,
  511. contractProductList: [],
  512. contractProjectList: [],
  513. fileList: [],
  514. packageFileList: [],
  515. contractShipmentList: [],
  516. },
  517. });
  518. const submit = ref(null);
  519. const judgeStatus = () => {
  520. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  521. let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
  522. if (data && data.length > 0) {
  523. return true;
  524. }
  525. }
  526. return false;
  527. };
  528. const formOption = reactive({
  529. inline: true,
  530. labelWidth: 100,
  531. itemWidth: 100,
  532. rules: [],
  533. disabled: judgeStatus()
  534. });
  535. const uploadData = ref({});
  536. const indicationUploadData = ref({});
  537. const formConfig = computed(() => {
  538. return [
  539. {
  540. type: "title",
  541. title: "合同模板",
  542. label: "",
  543. },
  544. {
  545. type: "select",
  546. label: "选择合同模板",
  547. prop: "contractTemplateId",
  548. data: templateList.value,
  549. fn: (val) => {
  550. changeTemplate(val);
  551. },
  552. },
  553. {
  554. type: "slot",
  555. slotName: "seller",
  556. label: "卖方信息",
  557. itemWidth: 50,
  558. },
  559. {
  560. type: "slot",
  561. slotName: "buyer",
  562. label: "买方信息",
  563. itemWidth: 50,
  564. },
  565. {
  566. type: "slot",
  567. slotName: "payment",
  568. label: "付款信息",
  569. },
  570. {
  571. type: "slot",
  572. slotName: "delivery",
  573. label: "交付信息",
  574. },
  575. {
  576. type: "slot",
  577. slotName: "commodity",
  578. label: "商品信息",
  579. },
  580. {
  581. type: "slot",
  582. slotName: "file",
  583. label: "交接单",
  584. },
  585. {
  586. type: "slot",
  587. slotName: "indication",
  588. label: "包装指示",
  589. },
  590. {
  591. type: "slot",
  592. slotName: "otherCharge",
  593. label: "其他收费项目",
  594. },
  595. {
  596. type: "slot",
  597. slotName: "offerMoney",
  598. },
  599. {
  600. type: "slot",
  601. slotName: "shipment",
  602. label: "出货计划",
  603. },
  604. ];
  605. });
  606. const rules = ref({
  607. contractTemplateId: [{ required: true, message: "请选择合同模板", trigger: "change" }],
  608. buyCorporationId: [{ required: true, message: "请选择公司", trigger: "change" }],
  609. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  610. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  611. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  612. buyContactName: [{ required: true, message: "请输入联系人", trigger: ["change", "blur"] }],
  613. buyContactNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  614. productName: [{ required: true, message: "请输入商品名称", trigger: "blur" }],
  615. productModel: [{ required: true, message: "请输入尺寸 cm*cm*cm", trigger: "blur" }],
  616. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  617. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  618. packMethod: [{ required: true, message: "请输入包装方式", trigger: "blur" }],
  619. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  620. payName: [{ required: true, message: "请输入收费项目", trigger: ["change", "blur"] }],
  621. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  622. effective: [{ required: true, message: "请输入报价有效期", trigger: "blur" }],
  623. deliveryTime: [{ required: true, message: "请选择交货期限", trigger: "change" }],
  624. paymentMethod: [{ required: true, message: "请选择付款方式", trigger: "change" }],
  625. advanceRatio: [{ required: true, message: "请输入预付比例", trigger: "blur" }],
  626. shroffAccountId: [{ required: true, message: "请选择收款账号", trigger: "change" }],
  627. tradeMethods: [{ required: true, message: "请选择贸易方式", trigger: "change" }],
  628. transportMethod: [{ required: true, message: "请选择运输方式", trigger: "change" }],
  629. transportRemark: [{ required: true, message: "请输入运输说明", trigger: "blur" }],
  630. remark: [{ required: true, message: "请输入付款条件", trigger: "blur" }],
  631. });
  632. const getDict = () => {
  633. proxy
  634. .getDictOne([
  635. "inner_packaging_method_ehsd",
  636. "outside_packaging_method_ehsd",
  637. "account_currency",
  638. "funds_payment_method",
  639. "trade_methods",
  640. "shipping_method",
  641. ])
  642. .then((res) => {
  643. innerMethod.value = res["inner_packaging_method_ehsd"].map((x) => ({
  644. label: x.dictValue,
  645. value: x.dictKey,
  646. }));
  647. outsideMethod.value = res["outside_packaging_method_ehsd"].map((x) => ({
  648. label: x.dictValue,
  649. value: x.dictKey,
  650. }));
  651. accountCurrency.value = res["account_currency"].map((x) => ({
  652. label: x.dictValue,
  653. value: x.dictKey,
  654. }));
  655. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  656. label: x.dictValue,
  657. value: x.dictKey,
  658. }));
  659. tradeMethods.value = res["trade_methods"].map((x) => ({
  660. label: x.dictValue,
  661. value: x.dictKey,
  662. }));
  663. shippingMethod.value = res["shipping_method"].map((x) => ({
  664. label: x.dictValue,
  665. value: x.dictKey,
  666. }));
  667. });
  668. proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  669. templateList.value = res.rows.map((item) => {
  670. return {
  671. ...item,
  672. label: item.templateName,
  673. value: item.id,
  674. };
  675. });
  676. });
  677. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  678. corporationList.value = res.rows.map((item) => {
  679. return {
  680. ...item,
  681. label: item.name,
  682. value: item.id,
  683. };
  684. });
  685. });
  686. proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  687. customerList.value = res.rows.map((item) => {
  688. return {
  689. ...item,
  690. label: item.name,
  691. value: item.id,
  692. };
  693. });
  694. });
  695. proxy.post("/accountManagement/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  696. accountList.value = res.rows.map((item) => {
  697. return {
  698. ...item,
  699. label: item.alias,
  700. value: item.id,
  701. };
  702. });
  703. });
  704. };
  705. getDict();
  706. const changeTemplate = (val) => {
  707. formData.data.sellCorporationId = "";
  708. formData.data.sellContactName = "";
  709. formData.data.sellContactNumber = "";
  710. formData.data.sellCountryName = "";
  711. formData.data.sellProvinceName = "";
  712. formData.data.sellCityName = "";
  713. formData.data.sellAddress = "";
  714. if (val) {
  715. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  716. formData.data.sellCorporationId = res.corporationId;
  717. if (res.corporationId) {
  718. proxy.post("/corporation/detail", { id: res.corporationId }).then((detailCorporation) => {
  719. proxy.post("/customizeArea/list", { parentId: "0" }).then((resCountry) => {
  720. let sellCountryData = resCountry.filter((item) => item.id === detailCorporation.countryId);
  721. if (sellCountryData && sellCountryData.length > 0) {
  722. formData.data.sellCountryName = sellCountryData[0].chineseName;
  723. } else {
  724. formData.data.sellCountryName = "";
  725. }
  726. });
  727. if (detailCorporation.countryId) {
  728. proxy.post("/customizeArea/list", { parentId: detailCorporation.countryId }).then((resProvince) => {
  729. let sellProvinceData = resProvince.filter((item) => item.id === detailCorporation.provinceId);
  730. if (sellProvinceData && sellProvinceData.length > 0) {
  731. formData.data.sellProvinceName = sellProvinceData[0].name;
  732. } else {
  733. formData.data.sellProvinceName = "";
  734. }
  735. });
  736. } else {
  737. formData.data.sellProvinceName = "";
  738. }
  739. if (detailCorporation.provinceId) {
  740. proxy.post("/customizeArea/list", { parentId: detailCorporation.provinceId }).then((resCity) => {
  741. let sellCityData = resCity.filter((item) => item.id === detailCorporation.cityId);
  742. if (sellCityData && sellCityData.length > 0) {
  743. formData.data.sellCityName = sellCityData[0].name;
  744. } else {
  745. formData.data.sellCityName = "";
  746. }
  747. });
  748. } else {
  749. formData.data.sellCityName = "";
  750. }
  751. formData.data.sellAddress = detailCorporation.address;
  752. });
  753. }
  754. formData.data.sellContactName = res.contactName;
  755. formData.data.sellContactNumber = res.contactNumber;
  756. });
  757. }
  758. };
  759. const getCityData = (id, type, isChange) => {
  760. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  761. if (type === "20") {
  762. provinceData.value = res;
  763. if (isChange) {
  764. formData.data.provinceId = "";
  765. formData.data.provinceName = "";
  766. formData.data.cityId = "";
  767. formData.data.cityName = "";
  768. }
  769. } else if (type === "30") {
  770. cityData.value = res;
  771. if (isChange) {
  772. formData.data.cityId = "";
  773. formData.data.cityName = "";
  774. }
  775. } else {
  776. countryData.value = res;
  777. }
  778. });
  779. };
  780. getCityData("0");
  781. const changeCustomer = (val) => {
  782. formData.data.contractProductList = [];
  783. formData.data.customerName = "";
  784. formData.data.customerTel = "";
  785. if (val) {
  786. proxy.post("/customer/detail", { id: val }).then(
  787. (res) => {
  788. if (res.customerUserList && res.customerUserList.length > 0) {
  789. formData.data.buyContactName = res.customerUserList[0].name;
  790. if (res.customerUserList[0].contactJson) {
  791. let contactJson = JSON.parse(res.customerUserList[0].contactJson);
  792. if (contactJson && contactJson.length > 0) {
  793. formData.data.buyContactNumber = contactJson[0].contactNo;
  794. }
  795. }
  796. customerUserList.value = res.customerUserList.map((item) => {
  797. return {
  798. ...item,
  799. value: item.name,
  800. };
  801. });
  802. }
  803. formData.data.countryId = res.countryId;
  804. formData.data.provinceId = res.provinceId;
  805. formData.data.cityId = res.cityId;
  806. formData.data.buyPostalCode = res.zipCode;
  807. formData.data.buyAddress = res.address;
  808. getCityData(formData.data.countryId, "20");
  809. if (formData.data.provinceId) {
  810. getCityData(formData.data.provinceId, "30");
  811. }
  812. },
  813. (err) => {
  814. console.log(err);
  815. formData.data.countryId = "";
  816. formData.data.provinceId = "";
  817. formData.data.cityId = "";
  818. formData.data.buyPostalCode = "";
  819. formData.data.buyAddress = "";
  820. }
  821. );
  822. } else {
  823. formData.data.countryId = "";
  824. formData.data.provinceId = "";
  825. formData.data.cityId = "";
  826. formData.data.buyPostalCode = "";
  827. formData.data.buyAddress = "";
  828. }
  829. };
  830. const createFilter = (queryString) => {
  831. return (restaurant) => {
  832. return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
  833. };
  834. };
  835. const querySearchPerson = (queryString, callback) => {
  836. const results = queryString ? customerUserList.value.filter(createFilter(queryString)) : customerUserList.value;
  837. callback(results);
  838. };
  839. const handlePerson = (item) => {
  840. formData.data.customerTel = item.phone;
  841. };
  842. const selectProduct = (goods) => {
  843. if (goods && goods.id) {
  844. let data = formData.data.contractProductList.filter((item) => item.productId === goods.id);
  845. if (data && data.length > 0) {
  846. return ElMessage("该产品已添加");
  847. }
  848. let fileUrl = "";
  849. if (goods.fileList && goods.fileList.length > 0) {
  850. fileUrl = goods.fileList[0].fileUrl;
  851. }
  852. let packMethod = "";
  853. if (goods.innerPackMethod) {
  854. let innerPackMethod = goods.innerPackMethod.split(",");
  855. innerPackMethod.map((item) => {
  856. if (packMethod) {
  857. packMethod = packMethod + "," + proxy.dictValueLabel(item, innerMethod.value);
  858. } else {
  859. packMethod = proxy.dictValueLabel(item, innerMethod.value);
  860. }
  861. });
  862. }
  863. if (goods.outerPackMethod) {
  864. let outerPackMethod = goods.outerPackMethod.split(",");
  865. outerPackMethod.map((item) => {
  866. if (packMethod) {
  867. packMethod = packMethod + "," + proxy.dictValueLabel(item, outsideMethod.value);
  868. } else {
  869. packMethod = proxy.dictValueLabel(item, outsideMethod.value);
  870. }
  871. });
  872. }
  873. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  874. formData.data.contractProductList.push({
  875. fileUrl: fileUrl,
  876. productId: goods.id,
  877. productName: goods.name,
  878. productModel: goods.productLong + "*" + goods.productWide + "*" + goods.productHigh,
  879. quantity: undefined,
  880. price: undefined,
  881. amount: "",
  882. tradeMethods: "",
  883. packMethod: packMethod,
  884. });
  885. } else {
  886. formData.data.contractProductList = [
  887. {
  888. fileUrl: fileUrl,
  889. productId: goods.id,
  890. productName: goods.name,
  891. productModel: goods.productLong + "*" + goods.productWide + "*" + goods.productHigh,
  892. quantity: undefined,
  893. price: undefined,
  894. amount: "",
  895. tradeMethods: "",
  896. packMethod: packMethod,
  897. },
  898. ];
  899. }
  900. formData.data.contractShipmentList.push({
  901. code: goods.code,
  902. productId: goods.id,
  903. productName: goods.name,
  904. shipmentTime: "",
  905. quantity: undefined,
  906. });
  907. ElMessage({
  908. message: "添加成功!",
  909. type: "success",
  910. });
  911. } else {
  912. return ElMessage("选择错误");
  913. }
  914. };
  915. const onPicture = (path) => {
  916. window.open(path, "_blank");
  917. };
  918. const handleRemove = async (index, row) => {
  919. formData.data.contractShipmentList = formData.data.contractShipmentList.filter((item) => item.productId !== row.productId);
  920. await formData.data.contractProductList.splice(index, 1);
  921. totalAmount();
  922. };
  923. const calculationAmount = () => {
  924. nextTick(() => {
  925. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  926. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  927. let money = 0;
  928. if (formData.data.contractProductList[i].quantity && formData.data.contractProductList[i].price) {
  929. money = parseFloat(Number(formData.data.contractProductList[i].quantity) * Number(formData.data.contractProductList[i].price)).toFixed(2);
  930. }
  931. formData.data.contractProductList[i].amount = money;
  932. }
  933. }
  934. nextTick(() => {
  935. totalAmount();
  936. });
  937. });
  938. };
  939. const totalAmount = () => {
  940. let money = 0;
  941. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  942. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  943. if (formData.data.contractProductList[i].amount) {
  944. money = parseFloat(Number(money) + Number(formData.data.contractProductList[i].amount)).toFixed(2);
  945. }
  946. }
  947. }
  948. if (formData.data.contractProjectList && formData.data.contractProjectList.length > 0) {
  949. for (let i = 0; i < formData.data.contractProjectList.length; i++) {
  950. if (formData.data.contractProjectList[i].amount) {
  951. money = parseFloat(Number(money) + Number(formData.data.contractProjectList[i].amount)).toFixed(2);
  952. }
  953. }
  954. }
  955. formData.data.amount = money;
  956. };
  957. const clickAdd = () => {
  958. if (formData.data.contractProjectList && formData.data.contractProjectList.length > 0) {
  959. formData.data.contractProjectList.push({
  960. payName: "",
  961. amount: undefined,
  962. remark: "",
  963. });
  964. } else {
  965. formData.data.contractProjectList = [{ payName: "", amount: undefined, remark: "" }];
  966. }
  967. };
  968. const handleDelete = async (index) => {
  969. await formData.data.contractProjectList.splice(index, 1);
  970. totalAmount();
  971. };
  972. const querySearch = (queryString, callback) => {
  973. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  974. if (res.rows && res.rows.length > 0) {
  975. res.rows = res.rows.map((item) => {
  976. return {
  977. ...item,
  978. value: item.payName,
  979. };
  980. });
  981. callback(res.rows);
  982. } else {
  983. callback([]);
  984. }
  985. });
  986. };
  987. const handleSubmit = async () => {
  988. let status = await submit.value.handleSubmit(() => {});
  989. if (status) {
  990. if (!(formData.data.contractProductList && formData.data.contractProductList.length > 0)) {
  991. ElMessage("请添加至少一件商品");
  992. return false;
  993. }
  994. if (formData.data.fileList && formData.data.fileList.length > 0) {
  995. for (let i = 0; i < formData.data.fileList.length; i++) {
  996. if (formData.data.fileList[i].raw.uploadState) {
  997. ElMessage("文件上传中,请稍后提交");
  998. return false;
  999. }
  1000. }
  1001. }
  1002. if (formData.data.packageFileList && formData.data.packageFileList.length > 0) {
  1003. for (let i = 0; i < formData.data.packageFileList.length; i++) {
  1004. if (formData.data.packageFileList[i].raw.uploadState) {
  1005. ElMessage("文件上传中,请稍后提交");
  1006. return false;
  1007. }
  1008. }
  1009. }
  1010. if (formData.data.contractShipmentList && formData.data.contractShipmentList.length > 0) {
  1011. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1012. let data = formData.data.contractShipmentList.filter((item) => item.productId === formData.data.contractProductList[i].productId);
  1013. if (data && data.length > 0) {
  1014. let quantity = 0;
  1015. for (let j = 0; j < data.length; j++) {
  1016. quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
  1017. }
  1018. if (quantity > formData.data.contractProductList[i].quantity) {
  1019. ElMessage("出货数量不能大于商品数量");
  1020. return false;
  1021. }
  1022. }
  1023. }
  1024. }
  1025. return true;
  1026. } else {
  1027. setTimeout(() => {
  1028. const errorDiv = document.getElementsByClassName("is-error");
  1029. errorDiv[0].scrollIntoView();
  1030. }, 0);
  1031. }
  1032. return status;
  1033. };
  1034. // 接收父组件的传值
  1035. const props = defineProps({
  1036. queryData: Object,
  1037. });
  1038. const clickCustomerProduct = () => {
  1039. if (!formData.data.buyCorporationId) {
  1040. return ElMessage("请先选择客户");
  1041. }
  1042. openProductCustomer.value = true;
  1043. };
  1044. const getFormData = () => {
  1045. return formData.data;
  1046. };
  1047. // 向父组件暴露
  1048. defineExpose({
  1049. getFormData,
  1050. handleSubmit,
  1051. });
  1052. const changeShroffAccount = (val) => {
  1053. if (val) {
  1054. let data = accountList.value.filter((item) => item.value === val);
  1055. if (data && data.length > 0) {
  1056. formData.data.beneficiaryName = data[0].beneficiaryName;
  1057. formData.data.beneficiaryBank = data[0].beneficiaryBank;
  1058. formData.data.beneficiaryBankAddress = data[0].beneficiaryBankAddress;
  1059. formData.data.beneficiaryAccountNumber = data[0].beneficiaryAccountNumber;
  1060. formData.data.swiftCode = data[0].swiftCode;
  1061. formData.data.beneficiaryAddress = data[0].beneficiaryAddress;
  1062. }
  1063. }
  1064. };
  1065. const changeActiveName = () => {
  1066. if (activeName.value) {
  1067. activeName.value = "";
  1068. } else {
  1069. activeName.value = "1";
  1070. }
  1071. };
  1072. const uploadFile = async (file) => {
  1073. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1074. uploadData.value = res.uploadBody;
  1075. file.id = res.id;
  1076. file.fileName = res.fileName;
  1077. file.fileUrl = res.fileUrl;
  1078. file.uploadState = true;
  1079. return true;
  1080. };
  1081. const indicationUploadFile = async (file) => {
  1082. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1083. indicationUploadData.value = res.uploadBody;
  1084. file.id = res.id;
  1085. file.fileName = res.fileName;
  1086. file.fileUrl = res.fileUrl;
  1087. file.uploadState = true;
  1088. return true;
  1089. };
  1090. const handleSuccess = (any, UploadFile) => {
  1091. UploadFile.raw.uploadState = false;
  1092. };
  1093. const onPreviewFile = (file) => {
  1094. window.open(file.raw.fileUrl, "_blank");
  1095. };
  1096. const clickSplit = (item) => {
  1097. formData.data.contractShipmentList.push({
  1098. code: item.code,
  1099. productId: item.productId,
  1100. productName: item.productName,
  1101. shipmentTime: "",
  1102. quantity: undefined,
  1103. });
  1104. };
  1105. const clickDelete = (index) => {
  1106. formData.data.contractShipmentList.splice(index, 1);
  1107. };
  1108. </script>
  1109. <style lang="scss" scoped>
  1110. ::v-deep(.el-input-number .el-input__inner) {
  1111. text-align: left;
  1112. }
  1113. .pic {
  1114. object-fit: contain;
  1115. width: 50px;
  1116. height: 50px;
  1117. cursor: pointer;
  1118. vertical-align: middle;
  1119. }
  1120. .shrinkPadding {
  1121. padding-right: 0 !important;
  1122. }
  1123. .hideCollapse {
  1124. margin-top: -62px;
  1125. border: 0 !important;
  1126. }
  1127. ::v-deep(.el-collapse-item__arrow) {
  1128. display: none !important;
  1129. }
  1130. ::v-deep(.el-collapse-item__wrap) {
  1131. border: 0 !important;
  1132. }
  1133. ::v-deep(.el-collapse-item__header) {
  1134. border: 0 !important;
  1135. }
  1136. </style>