Contract.vue 38 KB

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