Contract.vue 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  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" filterable 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="formData.data.contractType == '2' ? item.chineseName : item.name" :value="item.id">
  62. </el-option>
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="6">
  67. <el-form-item label=" " prop="provinceName">
  68. <selectCity
  69. placeholder="省/洲"
  70. @change="(val) => getCityData(val, '30', true)"
  71. addressId="provinceId"
  72. addressName="provinceName"
  73. v-model="formData.data"
  74. :data="provinceData">
  75. </selectCity>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6">
  79. <el-form-item label=" " prop="cityName">
  80. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData"> </selectCity>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="6">
  84. <el-form-item label=" " prop="buyPostalCode">
  85. <el-input v-model="formData.data.buyPostalCode" placeholder="请输入邮编" />
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. <el-row style="margin-top: 20px; width: 100%">
  90. <el-col :span="24">
  91. <el-form-item prop="buyAddress">
  92. <el-input v-model="formData.data.buyAddress" type="textarea"> </el-input>
  93. </el-form-item>
  94. </el-col>
  95. </el-row>
  96. <el-row style="margin-top: 20px; width: 100%">
  97. <el-col :span="8">
  98. <el-form-item label="联系人" prop="buyContactName">
  99. <el-autocomplete
  100. v-model="formData.data.buyContactName"
  101. :fetch-suggestions="querySearchPerson"
  102. clearable
  103. class="inline-input w-50"
  104. placeholder="请输入联系人"
  105. @select="handlePerson">
  106. </el-autocomplete>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="16">
  110. <el-form-item label=" " prop="buyContactNumber">
  111. <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. </div>
  116. </div>
  117. </template>
  118. <template #commodity>
  119. <div style="width: 100%">
  120. <el-button @click="openProduct = true">添加商品</el-button>
  121. <el-table :data="formData.data.contractProductList" style="width: 100%; margin-top: 16px">
  122. <el-table-column label="商品图片" width="80">
  123. <template #default="{ row }">
  124. <div v-if="row.productId">
  125. <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  126. </div>
  127. <div v-else></div>
  128. </template>
  129. </el-table-column>
  130. <el-table-column prop="code" label="商品编码" width="120" />
  131. <el-table-column prop="name" label="商品中文名" width="160" />
  132. <el-table-column label="商品英文名" min-width="200">
  133. <template #default="{ row, $index }">
  134. <div style="width: 100%">
  135. <el-form-item :prop="'contractProductList.' + $index + '.productName'" :rules="rules.productName" :inline-message="true">
  136. <el-input v-model="row.productName" placeholder="请输入商品英文名" />
  137. </el-form-item>
  138. </div>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="规格型号" width="180">
  142. <template #default="{ row, $index }">
  143. <div style="width: 100%">
  144. <el-form-item :prop="'contractProductList.' + $index + '.productModel'" :inline-message="true">
  145. <el-input v-model="row.productModel" placeholder="请输入规格型号" />
  146. </el-form-item>
  147. </div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="unit" label="单位" width="100" :formatter="(row) => dictValueLabel(row.unit, productUnit)" />
  151. <el-table-column label="数量" width="150">
  152. <template #default="{ row, $index }">
  153. <div style="width: 100%">
  154. <el-form-item :prop="'contractProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
  155. <el-input-number
  156. onmousewheel="return false;"
  157. v-model="row.quantity"
  158. placeholder="请输入数量"
  159. style="width: 100%"
  160. :precision="4"
  161. :controls="false"
  162. :min="0"
  163. @change="calculationAmount()" />
  164. </el-form-item>
  165. </div>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="单价" width="160">
  169. <template #default="{ row, $index }">
  170. <div style="width: 100%">
  171. <el-form-item :prop="'contractProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true">
  172. <el-input-number
  173. onmousewheel="return false;"
  174. v-model="row.price"
  175. placeholder="请输入单价"
  176. style="width: 100%"
  177. :precision="2"
  178. :controls="false"
  179. :min="0"
  180. @change="calculationAmount()" />
  181. </el-form-item>
  182. </div>
  183. </template>
  184. </el-table-column>
  185. <el-table-column prop="amount" label="金额" width="100" />
  186. <el-table-column align="center" label="操作" width="120" fixed="right">
  187. <template #default="{ row, $index }">
  188. <el-button type="primary" link @click="handleHandover(row, $index)">交接单</el-button>
  189. <el-button type="primary" link @click="handleRemove($index, row)">删除</el-button>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. </div>
  194. </template>
  195. <template #otherCharge>
  196. <div style="width: 100%">
  197. <el-button type="primary" @click="clickAdd()">添加行</el-button>
  198. <el-table :data="formData.data.contractProjectList" style="width: 100%; margin-top: 16px">
  199. <el-table-column label="收费项目" width="220">
  200. <template #default="{ row, $index }">
  201. <div style="width: 100%">
  202. <el-form-item :prop="'contractProjectList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true">
  203. <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50" placeholder="请输入收费项目" />
  204. </el-form-item>
  205. </div>
  206. </template>
  207. </el-table-column>
  208. <el-table-column label="金额" width="180">
  209. <template #default="{ row, $index }">
  210. <div style="width: 100%">
  211. <el-form-item :prop="'contractProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true">
  212. <el-input-number
  213. onmousewheel="return false;"
  214. v-model="row.amount"
  215. placeholder="请输入金额"
  216. style="width: 100%"
  217. :precision="2"
  218. :controls="false"
  219. :min="0"
  220. @change="totalAmount()" />
  221. </el-form-item>
  222. </div>
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="备注">
  226. <template #default="{ row, $index }">
  227. <div style="width: 100%">
  228. <el-form-item :prop="'contractProjectList.' + $index + '.remark'">
  229. <el-input v-model="row.remark" placeholder="请输入备注" />
  230. </el-form-item>
  231. </div>
  232. </template>
  233. </el-table-column>
  234. <el-table-column align="center" label="操作" width="80" fixed="right">
  235. <template #default="{ row, $index }">
  236. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  237. </template>
  238. </el-table-column>
  239. </el-table>
  240. </div>
  241. </template>
  242. <template #offerMoney>
  243. <div style="width: 100%">
  244. <el-row style="margin-top: 20px; width: 100%">
  245. <el-col :span="4">
  246. <el-form-item label="币种" prop="currency">
  247. <el-select v-model="formData.data.currency" placeholder="请选择币种" style="width: 100%">
  248. <el-option v-for="item in accountCurrency" :key="item.value" :label="item.label" :value="item.value" />
  249. </el-select>
  250. </el-form-item>
  251. </el-col>
  252. <el-col :span="6">
  253. <el-form-item label="合同总金额" prop="amount">
  254. <el-input v-model="formData.data.amount" placeholder="合同总金额" disabled />
  255. </el-form-item>
  256. </el-col>
  257. <!-- <el-col :span="4">
  258. <el-form-item label="报价有效期 (天)" prop="effective">
  259. <el-input-number onmousewheel="return false;"
  260. v-model="formData.data.effective"
  261. placeholder="请输入有效期"
  262. style="width: 100%"
  263. :precision="0"
  264. :controls="false"
  265. :min="0"
  266. />
  267. </el-form-item>
  268. </el-col> -->
  269. </el-row>
  270. <el-row style="margin-top: 20px; width: 100%">
  271. <el-col :span="7">
  272. <el-form-item label="付款方式" prop="paymentMethod">
  273. <el-select v-model="formData.data.paymentMethod" placeholder="请选择付款方式" style="width: 100%">
  274. <el-option v-for="item in fundsPaymentMethod" :key="item.value" :label="item.label" :value="item.value" />
  275. </el-select>
  276. </el-form-item>
  277. </el-col>
  278. <el-col :span="7">
  279. <el-form-item label="预付比例 (%)" prop="advanceRatio">
  280. <el-input-number
  281. onmousewheel="return false;"
  282. v-model="formData.data.advanceRatio"
  283. placeholder="请输入预付比例"
  284. style="width: 100%"
  285. :precision="2"
  286. :controls="false"
  287. :min="0"
  288. :max="100" />
  289. </el-form-item>
  290. </el-col>
  291. <el-col :span="7">
  292. <el-form-item label="收款账号" prop="shroffAccountId">
  293. <el-select v-model="formData.data.shroffAccountId" placeholder="请选择收款账号" style="width: 100%" @change="changeShroffAccount">
  294. <el-option v-for="item in accountList" :key="item.value" :label="item.label" :value="item.value" />
  295. </el-select>
  296. </el-form-item>
  297. </el-col>
  298. <el-col :span="3">
  299. <el-form-item label=" ">
  300. <el-button type="primary" @click="changeActiveName" text>
  301. <span v-if="activeName == '1'">收起</span>
  302. <span v-else>展开</span>
  303. </el-button>
  304. </el-form-item>
  305. </el-col>
  306. </el-row>
  307. <div style="width: 100%; margin-top: 34px">
  308. <el-collapse v-model="activeName" class="hideCollapse" accordion>
  309. <el-collapse-item title="" name="1">
  310. <el-row style="width: 100%">
  311. <el-col :span="9">
  312. <el-form-item label="Beneficiary Name" prop="beneficiaryName">
  313. <el-input v-model="formData.data.beneficiaryName" placeholder="请输入Beneficiary Name" />
  314. </el-form-item>
  315. <div style="height: 20px"></div>
  316. <el-form-item label="Beneficiary Bank" prop="beneficiaryBank">
  317. <el-input v-model="formData.data.beneficiaryBank" placeholder="请输入Beneficiary Bank" />
  318. </el-form-item>
  319. <div style="height: 20px"></div>
  320. <el-form-item label="Beneficiary Bank Address" prop="beneficiaryBankAddress">
  321. <el-input v-model="formData.data.beneficiaryBankAddress" placeholder="请输入Beneficiary Bank Address" />
  322. </el-form-item>
  323. </el-col>
  324. <el-col :span="9">
  325. <el-form-item label="Beneficiary Account Number" prop="beneficiaryAccountNumber">
  326. <el-input v-model="formData.data.beneficiaryAccountNumber" placeholder="请输入Beneficiary Account Number" />
  327. </el-form-item>
  328. <div style="height: 20px"></div>
  329. <el-form-item label="Swift Code" prop="swiftCode">
  330. <el-input v-model="formData.data.swiftCode" placeholder="请输入Swift Code" />
  331. </el-form-item>
  332. <div style="height: 20px"></div>
  333. <el-form-item label="Beneficiary Address" prop="beneficiaryAddress">
  334. <el-input v-model="formData.data.beneficiaryAddress" placeholder="请输入Beneficiary Address" />
  335. </el-form-item>
  336. </el-col>
  337. </el-row>
  338. </el-collapse-item>
  339. </el-collapse>
  340. </div>
  341. </div>
  342. </template>
  343. <template #delivery>
  344. <div style="width: 100%">
  345. <el-row style="margin-top: 20px; width: 100%">
  346. <el-col :span="7">
  347. <el-form-item label="贸易方式" prop="tradeMethods">
  348. <el-select v-model="formData.data.tradeMethods" placeholder="请选择贸易方式" style="width: 100%">
  349. <el-option v-for="item in tradeMethods" :key="item.value" :label="item.label" :value="item.value" />
  350. </el-select>
  351. </el-form-item>
  352. </el-col>
  353. </el-row>
  354. <el-row style="margin-top: 20px; width: 100%">
  355. <el-col :span="7">
  356. <el-form-item label="运输方式" prop="transportMethod">
  357. <el-select v-model="formData.data.transportMethod" placeholder="请选择运输方式" style="width: 100%">
  358. <el-option v-for="item in shippingMethod" :key="item.value" :label="item.label" :value="item.value" />
  359. </el-select>
  360. </el-form-item>
  361. </el-col>
  362. <el-col :span="7">
  363. <el-form-item label="运输说明" prop="transportRemark">
  364. <el-input v-model="formData.data.transportRemark" placeholder="请输入运输说明" />
  365. </el-form-item>
  366. </el-col>
  367. </el-row>
  368. <el-row style="margin-top: 20px; width: 100%">
  369. <el-col :span="14">
  370. <el-form-item label="付款条件" prop="remark">
  371. <el-input v-model="formData.data.remark" :rows="2" type="textarea" placeholder="请输入付款条件" />
  372. </el-form-item>
  373. </el-col>
  374. </el-row>
  375. <el-row style="margin-top: 20px; width: 100%">
  376. <el-col :span="7">
  377. <el-form-item label="交货期限 (天)" prop="deliveryTime">
  378. <!-- <el-date-picker v-model="formData.data.deliveryTime" type="date" placeholder="请选择交货期限" value-format="YYYY-MM-DD" /> -->
  379. <el-input-number
  380. onmousewheel="return false;"
  381. v-model="formData.data.deliveryTime"
  382. placeholder="请输入交货期限"
  383. style="width: 100%"
  384. :precision="0"
  385. :controls="false"
  386. :min="0" />
  387. </el-form-item>
  388. </el-col>
  389. <el-col :span="7">
  390. <el-form-item label="质保期 (天)" prop="warranty">
  391. <el-input-number
  392. onmousewheel="return false;"
  393. v-model="formData.data.warranty"
  394. placeholder="请输入质保期"
  395. style="width: 100%"
  396. :precision="0"
  397. :controls="false"
  398. :min="0" />
  399. </el-form-item>
  400. </el-col>
  401. </el-row>
  402. </div>
  403. </template>
  404. <template #shipment>
  405. <div style="width: 100%">
  406. <el-table :data="formData.data.contractShipmentList" style="width: 100%; margin-top: 16px">
  407. <el-table-column prop="code" label="商品编码" width="120" />
  408. <el-table-column prop="productName" label="商品名称" />
  409. <el-table-column label="出货日期" width="220">
  410. <template #default="{ row, $index }">
  411. <div style="width: 100%">
  412. <el-form-item :prop="'contractShipmentList.' + $index + '.shipmentTime'" :rules="rules.shipmentTime" :inline-message="true">
  413. <el-date-picker v-model="row.shipmentTime" type="date" placeholder="请选择出货日期" value-format="YYYY-MM-DD" />
  414. </el-form-item>
  415. </div>
  416. </template>
  417. </el-table-column>
  418. <el-table-column label="数量" width="160">
  419. <template #default="{ row, $index }">
  420. <div style="width: 100%">
  421. <el-form-item :prop="'contractShipmentList.' + $index + '.quantity'" :inline-message="true">
  422. <el-input-number
  423. onmousewheel="return false;"
  424. v-model="row.quantity"
  425. placeholder="请输入数量"
  426. style="width: 100%"
  427. :precision="4"
  428. :controls="false"
  429. :min="0"
  430. @change="calculationAmount()" />
  431. </el-form-item>
  432. </div>
  433. </template>
  434. </el-table-column>
  435. <el-table-column align="center" label="操作" width="120" fixed="right">
  436. <template #default="{ row, $index }">
  437. <el-button type="primary" link @click="clickSplit(row)">拆分</el-button>
  438. <el-button type="primary" link @click="clickDelete($index)">删除</el-button>
  439. </template>
  440. </el-table-column>
  441. </el-table>
  442. </div>
  443. </template>
  444. </byForm>
  445. <el-dialog v-if="openProduct" v-model="openProduct" title="选择商品" width="70%" append-to-body>
  446. <SelectGoods :selectList="acquireSelectList()" @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
  447. </el-dialog>
  448. <el-dialog title="交接单" v-if="openHandover" v-model="openHandover" width="800">
  449. <byForm :formConfig="formHandoverConfig" :formOption="formOption" v-model="productRow.data">
  450. <template #remark>
  451. <div style="width: 100%">
  452. <Editor :value="productRow.data.remark" @updateValue="updateContent" />
  453. </div>
  454. </template>
  455. <template #file>
  456. <div style="width: 100%">
  457. <el-upload
  458. v-model:fileList="fileList"
  459. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  460. :data="uploadData"
  461. multiple
  462. :before-upload="uploadFile"
  463. :on-success="handleSuccess"
  464. :on-preview="onPreviewFile">
  465. <el-button>选择</el-button>
  466. </el-upload>
  467. </div>
  468. </template>
  469. </byForm>
  470. <template #footer>
  471. <el-button @click="openHandover = false" size="large">取 消</el-button>
  472. <el-button type="primary" @click="submitHandoverForm()" size="large">确 定</el-button>
  473. </template>
  474. </el-dialog>
  475. </div>
  476. </template>
  477. <script setup>
  478. import byForm from "@/components/byForm/index";
  479. import SelectGoods from "@/components/product/SelectGoods";
  480. import { ElMessage } from "element-plus";
  481. import Editor from "@/components/Editor/index.vue";
  482. import selectCity from "@/components/selectCity/index.vue";
  483. import { useRoute } from "vue-router";
  484. import Pubsub from "pubsub-js";
  485. const route = useRoute();
  486. // 接收父组件的传值
  487. const props = defineProps({
  488. queryData: String,
  489. });
  490. const { proxy } = getCurrentInstance();
  491. const contractType = 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 countryData = ref([]);
  500. const provinceData = ref([]);
  501. const cityData = ref([]);
  502. const customerUserList = ref([]);
  503. const accountList = ref([]);
  504. const productUnit = ref([]);
  505. const openProduct = ref(false);
  506. const activeName = ref("");
  507. const formData = reactive({
  508. data: {
  509. contractType: "1",
  510. amount: undefined,
  511. contractProductList: [],
  512. contractProjectList: [],
  513. contractShipmentList: [],
  514. },
  515. });
  516. const submit = ref(null);
  517. const judgeStatus = () => {
  518. if (route.query.processType == 20 || route.query.processType == 10) {
  519. return true;
  520. }
  521. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  522. let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
  523. if (data && data.length > 0) {
  524. return true;
  525. }
  526. }
  527. return false;
  528. };;
  529. const formOption = reactive({
  530. inline: true,
  531. labelWidth: 100,
  532. itemWidth: 100,
  533. rules: [],
  534. disabled: false,
  535. });
  536. const formConfig = computed(() => {
  537. return [
  538. {
  539. type: "title",
  540. title: "合同模板",
  541. label: "",
  542. },
  543. {
  544. type: "select",
  545. label: "合同类型",
  546. prop: "contractType",
  547. data: contractType.value,
  548. itemWidth: 25,
  549. },
  550. {
  551. type: "select",
  552. label: "选择合同模板",
  553. prop: "contractTemplateId",
  554. data: templateList.value,
  555. fn: (val) => {
  556. changeTemplate(val);
  557. },
  558. itemWidth: 26,
  559. },
  560. {
  561. type: "slot",
  562. slotName: "seller",
  563. label: "卖方信息",
  564. itemWidth: 50,
  565. },
  566. {
  567. type: "slot",
  568. slotName: "buyer",
  569. label: "买方信息",
  570. itemWidth: 50,
  571. },
  572. {
  573. type: "slot",
  574. slotName: "commodity",
  575. label: "商品信息",
  576. },
  577. {
  578. type: "slot",
  579. slotName: "otherCharge",
  580. label: "其他收费项目",
  581. },
  582. {
  583. type: "slot",
  584. slotName: "offerMoney",
  585. label: "收款信息",
  586. },
  587. {
  588. type: "slot",
  589. slotName: "delivery",
  590. label: "交付信息",
  591. },
  592. {
  593. type: "slot",
  594. slotName: "shipment",
  595. label: "出货计划",
  596. },
  597. ];
  598. });
  599. const rules = ref({
  600. contractType: [{ required: true, message: "请选择合同类型", trigger: "change" }],
  601. contractTemplateId: [{ required: true, message: "请选择合同模板", trigger: "change" }],
  602. buyCorporationId: [{ required: true, message: "请选择公司", trigger: "change" }],
  603. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  604. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  605. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  606. buyContactName: [{ required: true, message: "请输入联系人", trigger: ["change", "blur"] }],
  607. buyContactNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  608. productName: [{ required: true, message: "请输入商品英文名", trigger: "blur" }],
  609. productModel: [{ required: true, message: "请输入规格型号", trigger: "blur" }],
  610. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  611. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  612. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  613. payName: [{ required: true, message: "请输入收费项目", trigger: ["change", "blur"] }],
  614. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  615. effective: [{ required: true, message: "请输入报价有效期", trigger: "blur" }],
  616. deliveryTime: [{ required: true, message: "请选择交货期限", trigger: "blur" }],
  617. paymentMethod: [{ required: true, message: "请选择付款方式", trigger: "change" }],
  618. advanceRatio: [{ required: true, message: "请输入预付比例", trigger: "blur" }],
  619. shroffAccountId: [{ required: true, message: "请选择收款账号", trigger: "change" }],
  620. tradeMethods: [{ required: true, message: "请选择贸易方式", trigger: "change" }],
  621. transportMethod: [{ required: true, message: "请选择运输方式", trigger: "change" }],
  622. transportRemark: [{ required: true, message: "请输入运输说明", trigger: "blur" }],
  623. remark: [{ required: true, message: "请输入付款条件", trigger: "blur" }],
  624. });
  625. const getDict = () => {
  626. proxy.getDictOne(["account_currency", "funds_payment_method", "trade_mode", "shipping_method", "contract_type", "unit"]).then((res) => {
  627. accountCurrency.value = res["account_currency"].map((x) => ({
  628. label: x.dictValue,
  629. value: x.dictKey,
  630. }));
  631. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  632. label: x.dictValue,
  633. value: x.dictKey,
  634. }));
  635. tradeMethods.value = res["trade_mode"].map((x) => ({
  636. label: x.dictValue,
  637. value: x.dictKey,
  638. }));
  639. shippingMethod.value = res["shipping_method"].map((x) => ({
  640. label: x.dictValue,
  641. value: x.dictKey,
  642. }));
  643. contractType.value = res["contract_type"].map((x) => ({
  644. label: x.dictValue,
  645. value: x.dictKey,
  646. }));
  647. productUnit.value = res["unit"].map((x) => ({
  648. label: x.dictValue,
  649. value: x.dictKey,
  650. }));
  651. });
  652. proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  653. templateList.value = res.rows.map((item) => {
  654. return {
  655. ...item,
  656. label: item.templateName,
  657. value: item.id,
  658. };
  659. });
  660. });
  661. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  662. corporationList.value = res.rows.map((item) => {
  663. return {
  664. ...item,
  665. label: item.name,
  666. value: item.id,
  667. };
  668. });
  669. });
  670. proxy.post("/customer/privateSeaPage", { pageNum: 1, pageSize: 999 }).then((res) => {
  671. customerList.value = res.rows.map((item) => {
  672. return {
  673. ...item,
  674. label: item.name,
  675. value: item.id,
  676. };
  677. });
  678. });
  679. proxy.post("/accountManagement/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  680. accountList.value = res.rows.map((item) => {
  681. return {
  682. ...item,
  683. label: item.alias,
  684. value: item.id,
  685. };
  686. });
  687. });
  688. };
  689. getDict();
  690. const changeTemplate = (val) => {
  691. formData.data.sellCorporationId = "";
  692. formData.data.sellContactName = "";
  693. formData.data.sellContactNumber = "";
  694. formData.data.sellCountryName = "";
  695. formData.data.sellProvinceName = "";
  696. formData.data.sellCityName = "";
  697. formData.data.sellAddress = "";
  698. if (val) {
  699. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  700. formData.data.sellCorporationId = res.corporationId;
  701. if (res.corporationId) {
  702. proxy.post("/corporation/detail", { id: res.corporationId }).then((detailCorporation) => {
  703. if (detailCorporation.countryEnStr) {
  704. formData.data.sellCountryName = detailCorporation.countryEnStr;
  705. }
  706. if (detailCorporation.provinceEnStr) {
  707. formData.data.sellProvinceName = detailCorporation.provinceEnStr;
  708. }
  709. if (detailCorporation.cityEnStr) {
  710. formData.data.sellCityName = detailCorporation.cityEnStr;
  711. }
  712. if (detailCorporation.addressEn) {
  713. formData.data.sellAddress = detailCorporation.addressEn;
  714. }
  715. // proxy.post("/customizeArea/list", { parentId: "0" }).then((resCountry) => {
  716. // let sellCountryData = resCountry.filter((item) => item.id === detailCorporation.countryId);
  717. // if (sellCountryData && sellCountryData.length > 0) {
  718. // formData.data.sellCountryName = sellCountryData[0].chineseName;
  719. // } else {
  720. // formData.data.sellCountryName = "";
  721. // }
  722. // });
  723. // if (detailCorporation.countryId) {
  724. // proxy
  725. // .post("/customizeArea/list", {
  726. // parentId: detailCorporation.countryId,
  727. // })
  728. // .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
  741. // .post("/customizeArea/list", {
  742. // parentId: detailCorporation.provinceId,
  743. // })
  744. // .then((resCity) => {
  745. // let sellCityData = resCity.filter((item) => item.id === detailCorporation.cityId);
  746. // if (sellCityData && sellCityData.length > 0) {
  747. // formData.data.sellCityName = sellCityData[0].name;
  748. // } else {
  749. // formData.data.sellCityName = "";
  750. // }
  751. // });
  752. // } else {
  753. // formData.data.sellCityName = "";
  754. // }
  755. // formData.data.sellAddress = detailCorporation.address;
  756. });
  757. }
  758. formData.data.sellContactName = res.contactName;
  759. formData.data.sellContactNumber = res.contactNumber;
  760. });
  761. }
  762. };
  763. const getCityData = (id, type, isChange) => {
  764. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  765. if (type === "20") {
  766. provinceData.value = res;
  767. if (isChange) {
  768. formData.data.provinceId = "";
  769. formData.data.provinceName = "";
  770. formData.data.cityId = "";
  771. formData.data.cityName = "";
  772. }
  773. } else if (type === "30") {
  774. cityData.value = res;
  775. if (isChange) {
  776. formData.data.cityId = "";
  777. formData.data.cityName = "";
  778. }
  779. } else {
  780. countryData.value = res;
  781. }
  782. });
  783. };
  784. getCityData("0");
  785. const changeCustomer = (val) => {
  786. formData.data.buyContactName = "";
  787. formData.data.buyContactNumber = "";
  788. if (val) {
  789. proxy.post("/customer/detail", { id: val }).then(
  790. (res) => {
  791. if (res.customerUserList && res.customerUserList.length > 0) {
  792. formData.data.buyContactName = res.customerUserList[0].name;
  793. if (res.customerUserList[0].contactJson) {
  794. let contactJson = JSON.parse(res.customerUserList[0].contactJson);
  795. if (contactJson && contactJson.length > 0) {
  796. formData.data.buyContactNumber = contactJson[0].contactNo;
  797. }
  798. }
  799. customerUserList.value = res.customerUserList.map((item) => {
  800. return {
  801. ...item,
  802. value: item.name,
  803. };
  804. });
  805. }
  806. formData.data.countryId = res.countryId;
  807. formData.data.provinceId = res.provinceId;
  808. formData.data.cityId = res.cityId;
  809. formData.data.buyPostalCode = res.zipCode;
  810. formData.data.buyAddress = res.address;
  811. getCityData(formData.data.countryId, "20");
  812. if (formData.data.provinceId) {
  813. getCityData(formData.data.provinceId, "30");
  814. }
  815. },
  816. (err) => {
  817. console.log(err);
  818. formData.data.countryId = "";
  819. formData.data.provinceId = "";
  820. formData.data.cityId = "";
  821. formData.data.buyPostalCode = "";
  822. formData.data.buyAddress = "";
  823. }
  824. );
  825. } else {
  826. formData.data.countryId = "";
  827. formData.data.provinceId = "";
  828. formData.data.cityId = "";
  829. formData.data.buyPostalCode = "";
  830. formData.data.buyAddress = "";
  831. }
  832. getDecisionAids();
  833. };
  834. let auxiliaryData = ref([
  835. {
  836. label: "最近合同",
  837. data: [],
  838. },
  839. {
  840. label: "产品价格",
  841. data: [],
  842. },
  843. ]);
  844. const emit = defineEmits(["auxiliaryChange"]);
  845. const getDecisionAids = () => {
  846. let data = {
  847. buyCorporationId: formData.data.buyCorporationId,
  848. productIdList: [],
  849. };
  850. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  851. data.productIdList = formData.data.contractProductList.map((item) => item.productId);
  852. }
  853. proxy.post("/contract/decisionAid", data).then((res) => {
  854. if (res.lastContractList && res.lastContractList.length > 0) {
  855. auxiliaryData.value[0].data = res.lastContractList.map((item) => {
  856. return [
  857. {
  858. label: "合同编号",
  859. value: item.code,
  860. style: {
  861. color: "#0084FF",
  862. },
  863. id: item.id,
  864. num: 1,
  865. // fn: () => {},
  866. },
  867. {
  868. label: "下单日期",
  869. value: item.createTime,
  870. id: item.id,
  871. num: 1,
  872. },
  873. {
  874. label: "合同金额",
  875. value: item.currency + item.amount,
  876. id: item.id,
  877. num: 1,
  878. },
  879. ];
  880. });
  881. } else {
  882. auxiliaryData.value[0].data = [];
  883. }
  884. if (res.productPriceList && res.productPriceList.length > 0) {
  885. auxiliaryData.value[1].data = res.productPriceList.map((item) => {
  886. return [
  887. {
  888. label: "产品名称",
  889. value: item.name,
  890. id: item.id,
  891. num: 1,
  892. },
  893. {
  894. label: "最近价格",
  895. value: item.lastPrice,
  896. id: item.id,
  897. num: 1,
  898. },
  899. {
  900. label: "历史最高",
  901. value: item.maxPrice,
  902. id: item.id,
  903. num: 1,
  904. },
  905. {
  906. label: "历史最低",
  907. value: item.minPrice,
  908. id: item.id,
  909. num: 1,
  910. },
  911. ];
  912. });
  913. } else {
  914. auxiliaryData.value[1].data = [];
  915. }
  916. emit("auxiliaryChange", auxiliaryData.value);
  917. });
  918. };
  919. const createFilter = (queryString) => {
  920. return (restaurant) => {
  921. return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
  922. };
  923. };
  924. const querySearchPerson = (queryString, callback) => {
  925. const results = queryString ? customerUserList.value.filter(createFilter(queryString)) : customerUserList.value;
  926. callback(results);
  927. };
  928. const handlePerson = (item) => {
  929. formData.data.buyContactNumber = item.phone;
  930. };
  931. const pushGoods = (goods) => {
  932. if (goods && goods.length > 0) {
  933. let afterFiltering = [];
  934. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  935. afterFiltering = goods.filter((item) => {
  936. let data = formData.data.contractProductList.filter((itemProduct) => itemProduct.productId === item.id);
  937. if (data && data.length > 0) {
  938. return false;
  939. }
  940. return true;
  941. });
  942. } else {
  943. afterFiltering = goods;
  944. }
  945. formData.data.contractProductList = formData.data.contractProductList.concat(
  946. afterFiltering.map((item) => {
  947. let fileUrl = "";
  948. if (item.fileList && item.fileList.length > 0) {
  949. fileUrl = item.fileList[0].fileUrl;
  950. }
  951. let name = item.name;
  952. if (item.standardJson) {
  953. let standardJson = JSON.parse(item.standardJson);
  954. if (standardJson && standardJson.englishName) {
  955. name = standardJson.englishName;
  956. }
  957. }
  958. return {
  959. fileUrl: fileUrl,
  960. code: item.code,
  961. productId: item.id,
  962. name: item.name,
  963. productName: name,
  964. productModel: item.spec,
  965. unit: item.unit,
  966. quantity: undefined,
  967. price: undefined,
  968. amount: "",
  969. remark: "",
  970. fileList: [],
  971. };
  972. })
  973. );
  974. formData.data.contractShipmentList = formData.data.contractShipmentList.concat(
  975. afterFiltering.map((item) => {
  976. return {
  977. code: item.code,
  978. productId: item.id,
  979. productName: item.name,
  980. shipmentTime: "",
  981. quantity: undefined,
  982. };
  983. })
  984. );
  985. ElMessage({
  986. message: "添加成功!",
  987. type: "success",
  988. });
  989. openProduct.value = false;
  990. getDecisionAids();
  991. } else {
  992. ElMessage("请选择至少一件商品");
  993. }
  994. };
  995. const onPicture = (path) => {
  996. window.open(path, "_blank");
  997. };
  998. const productRow = reactive({
  999. data: {
  1000. productName: "",
  1001. productModel: "",
  1002. remark: "",
  1003. },
  1004. });
  1005. const productIndex = ref(0);
  1006. const openHandover = ref(false);
  1007. const fileList = ref([]);
  1008. const uploadData = ref({});
  1009. const formHandoverConfig = computed(() => {
  1010. return [
  1011. {
  1012. type: "title",
  1013. title: "产品信息",
  1014. label: "",
  1015. },
  1016. {
  1017. type: "input",
  1018. prop: "productName",
  1019. label: "产品名称",
  1020. itemType: "text",
  1021. disabled: true,
  1022. },
  1023. {
  1024. type: "input",
  1025. prop: "productModel",
  1026. label: "规格型号",
  1027. itemType: "text",
  1028. disabled: true,
  1029. },
  1030. {
  1031. type: "slot",
  1032. slotName: "remark",
  1033. label: "交接单",
  1034. },
  1035. {
  1036. type: "slot",
  1037. prop: "file",
  1038. slotName: "file",
  1039. label: "上传附件",
  1040. },
  1041. ];
  1042. });
  1043. const handleHandover = (row, index) => {
  1044. productRow.data = {
  1045. productName: row.productName,
  1046. productModel: row.productModel,
  1047. remark: row.remark,
  1048. };
  1049. if (row.fileList && row.fileList.length > 0) {
  1050. fileList.value = row.fileList.map((item) => {
  1051. return {
  1052. raw: item,
  1053. name: item.fileName,
  1054. url: item.fileUrl,
  1055. };
  1056. });
  1057. } else {
  1058. fileList.value = [];
  1059. }
  1060. productIndex.value = index;
  1061. openHandover.value = true;
  1062. };
  1063. const updateContent = (val) => {
  1064. productRow.data.remark = val;
  1065. };
  1066. const changeActiveName = () => {
  1067. if (activeName.value) {
  1068. activeName.value = "";
  1069. } else {
  1070. activeName.value = "1";
  1071. }
  1072. };
  1073. const uploadFile = async (file) => {
  1074. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1075. uploadData.value = res.uploadBody;
  1076. file.id = res.id;
  1077. file.fileName = res.fileName;
  1078. file.fileUrl = res.fileUrl;
  1079. file.uploadState = true;
  1080. return true;
  1081. };
  1082. const handleSuccess = (any, UploadFile) => {
  1083. UploadFile.raw.uploadState = false;
  1084. };
  1085. const onPreviewFile = (file) => {
  1086. window.open(file.raw.fileUrl, "_blank");
  1087. };
  1088. const submitHandoverForm = () => {
  1089. if (fileList.value && fileList.value.length > 0) {
  1090. for (let i = 0; i < fileList.value.length; i++) {
  1091. if (fileList.value[i].raw.uploadState) {
  1092. ElMessage("文件上传中,请稍后提交");
  1093. return;
  1094. }
  1095. }
  1096. formData.data.contractProductList[productIndex.value].fileList = fileList.value.map((item) => {
  1097. return {
  1098. id: item.raw.id,
  1099. fileName: item.raw.fileName,
  1100. fileUrl: item.raw.fileUrl,
  1101. uploadState: item.raw.uploadState,
  1102. };
  1103. });
  1104. } else {
  1105. formData.data.contractProductList[productIndex.value].fileList = [];
  1106. }
  1107. formData.data.contractProductList[productIndex.value].remark = productRow.data.remark;
  1108. openHandover.value = false;
  1109. };
  1110. const handleRemove = async (index, row) => {
  1111. formData.data.contractShipmentList = formData.data.contractShipmentList.filter((item) => item.productId !== row.productId);
  1112. await formData.data.contractProductList.splice(index, 1);
  1113. totalAmount();
  1114. getDecisionAids();
  1115. };
  1116. const calculationAmount = () => {
  1117. nextTick(() => {
  1118. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  1119. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1120. let money = 0;
  1121. if (formData.data.contractProductList[i].quantity && formData.data.contractProductList[i].price) {
  1122. money = parseFloat(Number(formData.data.contractProductList[i].quantity) * Number(formData.data.contractProductList[i].price)).toFixed(2);
  1123. }
  1124. formData.data.contractProductList[i].amount = money;
  1125. }
  1126. }
  1127. nextTick(() => {
  1128. totalAmount();
  1129. });
  1130. });
  1131. };
  1132. const totalAmount = () => {
  1133. let money = 0;
  1134. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  1135. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1136. if (formData.data.contractProductList[i].amount) {
  1137. money = parseFloat(Number(money) + Number(formData.data.contractProductList[i].amount)).toFixed(2);
  1138. }
  1139. }
  1140. }
  1141. if (formData.data.contractProjectList && formData.data.contractProjectList.length > 0) {
  1142. for (let i = 0; i < formData.data.contractProjectList.length; i++) {
  1143. if (formData.data.contractProjectList[i].amount) {
  1144. money = parseFloat(Number(money) + Number(formData.data.contractProjectList[i].amount)).toFixed(2);
  1145. }
  1146. }
  1147. }
  1148. formData.data.amount = money;
  1149. };
  1150. const clickAdd = () => {
  1151. if (formData.data.contractProjectList && formData.data.contractProjectList.length > 0) {
  1152. formData.data.contractProjectList.push({
  1153. payName: "",
  1154. amount: undefined,
  1155. remark: "",
  1156. });
  1157. } else {
  1158. formData.data.contractProjectList = [{ payName: "", amount: undefined, remark: "" }];
  1159. }
  1160. };
  1161. const handleDelete = async (index) => {
  1162. await formData.data.contractProjectList.splice(index, 1);
  1163. totalAmount();
  1164. };
  1165. const querySearch = (queryString, callback) => {
  1166. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  1167. if (res.rows && res.rows.length > 0) {
  1168. res.rows = res.rows.map((item) => {
  1169. return {
  1170. ...item,
  1171. value: item.payName,
  1172. };
  1173. });
  1174. callback(res.rows);
  1175. } else {
  1176. callback([]);
  1177. }
  1178. });
  1179. };
  1180. const clickSplit = (item) => {
  1181. formData.data.contractShipmentList.push({
  1182. code: item.code,
  1183. productId: item.productId,
  1184. productName: item.productName,
  1185. shipmentTime: "",
  1186. quantity: undefined,
  1187. });
  1188. };
  1189. const clickDelete = (index) => {
  1190. formData.data.contractShipmentList.splice(index, 1);
  1191. };
  1192. const handleSubmit = async () => {
  1193. let status = await submit.value.handleSubmit(() => {});
  1194. if (status) {
  1195. if (!(formData.data.contractProductList && formData.data.contractProductList.length > 0)) {
  1196. ElMessage("请添加至少一件商品");
  1197. return false;
  1198. }
  1199. if (formData.data.contractShipmentList && formData.data.contractShipmentList.length > 0) {
  1200. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1201. let data = formData.data.contractShipmentList.filter((item) => item.productId === formData.data.contractProductList[i].productId);
  1202. if (data && data.length > 0) {
  1203. let quantity = 0;
  1204. for (let j = 0; j < data.length; j++) {
  1205. quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
  1206. }
  1207. if (quantity > formData.data.contractProductList[i].quantity) {
  1208. ElMessage("出货数量不能大于商品数量");
  1209. return false;
  1210. }
  1211. }
  1212. }
  1213. }
  1214. return true;
  1215. } else {
  1216. setTimeout(() => {
  1217. const errorDiv = document.getElementsByClassName("is-error");
  1218. errorDiv[0].scrollIntoView();
  1219. }, 0);
  1220. }
  1221. return false;
  1222. };
  1223. const getFormData = () => {
  1224. return formData.data;
  1225. };
  1226. // 向父组件暴露
  1227. defineExpose({
  1228. getFormData,
  1229. handleSubmit,
  1230. });
  1231. const changeShroffAccount = (val) => {
  1232. if (val) {
  1233. let data = accountList.value.filter((item) => item.value === val);
  1234. if (data && data.length > 0) {
  1235. formData.data.beneficiaryName = data[0].beneficiaryName;
  1236. formData.data.beneficiaryBank = data[0].beneficiaryBank;
  1237. formData.data.beneficiaryBankAddress = data[0].beneficiaryBankAddress;
  1238. formData.data.beneficiaryAccountNumber = data[0].beneficiaryAccountNumber;
  1239. formData.data.swiftCode = data[0].swiftCode;
  1240. formData.data.beneficiaryAddress = data[0].beneficiaryAddress;
  1241. }
  1242. }
  1243. };
  1244. watch(
  1245. props.queryData,
  1246. () => {
  1247. formOption.disabled = judgeStatus();
  1248. if (props.queryData && ["10", "20", "30"].includes(route.query.processType)) {
  1249. for (var text in props.queryData) {
  1250. formData.data[text] = props.queryData[text];
  1251. }
  1252. if (formData.data.countryId) {
  1253. getCityData(formData.data.countryId, "20");
  1254. }
  1255. if (formData.data.provinceId) {
  1256. getCityData(formData.data.provinceId, "30");
  1257. }
  1258. getDecisionAids();
  1259. }
  1260. },
  1261. {
  1262. deep: true,
  1263. }
  1264. );
  1265. const acquireSelectList = () => {
  1266. let data = [];
  1267. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  1268. data = formData.data.contractProductList.map((item) => {
  1269. return {
  1270. id: item.productId,
  1271. name: item.name,
  1272. };
  1273. });
  1274. }
  1275. return data;
  1276. };
  1277. onMounted(() => {
  1278. if (props.queryData.priceSheetId) {
  1279. proxy.post("/saleQuotation/detail", { id: props.queryData.priceSheetId }).then((res) => {
  1280. console.log(res);
  1281. res.countryId = res.buyCountryId;
  1282. res.provinceId = res.buyProvinceId;
  1283. res.cityId = res.buyCityId;
  1284. for (var text in res) {
  1285. formData.data[text] = res[text];
  1286. }
  1287. if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
  1288. formData.data.contractProductList = formData.data.quotationProductList.map((item) => {
  1289. delete item.id;
  1290. return {
  1291. ...item,
  1292. };
  1293. });
  1294. formData.data.contractShipmentList = proxy.deepClone(
  1295. formData.data.contractProductList.map((item) => {
  1296. return {
  1297. ...item,
  1298. quantity: undefined,
  1299. };
  1300. })
  1301. );
  1302. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1303. proxy.post("/productInfo/detail", { id: formData.data.contractProductList[i].productId }).then((resProduct) => {
  1304. let name = resProduct.name;
  1305. if (resProduct.standardJson) {
  1306. let standardJson = JSON.parse(resProduct.standardJson);
  1307. if (standardJson && standardJson.englishName) {
  1308. name = standardJson.englishName;
  1309. }
  1310. }
  1311. formData.data.contractProductList[i].name = resProduct.name;
  1312. formData.data.contractProductList[i].productName = name;
  1313. formData.data.contractProductList[i].code = resProduct.code;
  1314. formData.data.contractProductList[i].unit = resProduct.unit;
  1315. formData.data.contractShipmentList[i].code = resProduct.code;
  1316. });
  1317. }
  1318. }
  1319. delete formData.data.id;
  1320. delete formData.data.code;
  1321. getCityData(formData.data.countryId, "20");
  1322. if (formData.data.provinceId) {
  1323. getCityData(formData.data.provinceId, "30");
  1324. }
  1325. if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
  1326. formData.data.contractProjectList = formData.data.quotationPayList.map((item) => {
  1327. delete item.id;
  1328. return {
  1329. ...item,
  1330. };
  1331. });
  1332. }
  1333. });
  1334. }
  1335. });
  1336. </script>
  1337. <style lang="scss" scoped>
  1338. ::v-deep(.el-input-number .el-input__inner) {
  1339. text-align: left;
  1340. }
  1341. .pic {
  1342. object-fit: contain;
  1343. width: 50px;
  1344. height: 50px;
  1345. cursor: pointer;
  1346. vertical-align: middle;
  1347. }
  1348. .shrinkPadding {
  1349. padding-right: 0 !important;
  1350. }
  1351. .hideCollapse {
  1352. margin-top: -62px;
  1353. border: 0 !important;
  1354. }
  1355. ::v-deep(.el-collapse-item__arrow) {
  1356. display: none !important;
  1357. }
  1358. ::v-deep(.el-collapse-item__wrap) {
  1359. border: 0 !important;
  1360. }
  1361. ::v-deep(.el-collapse-item__header) {
  1362. border: 0 !important;
  1363. }
  1364. </style>