Contract.vue 42 KB

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