Contract.vue 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom">
  4. <template #btn>
  5. <div>
  6. <el-button type="primary" v-if="
  7. [30].includes(route.query.processType) || !route.query.processType
  8. " @click="clickCopy(1)">复制合同</el-button>
  9. </div>
  10. </template>
  11. <template #seller>
  12. <div style="width: 100%">
  13. <el-form-item prop="sellCorporationId" label="卖方信息" class="wid100">
  14. <el-select v-model="formData.data.sellCorporationId" placeholder="请选择卖方公司" style="width: 100%" @change="sellCorporationIdChange"
  15. filterable>
  16. <el-option v-for="item in corporationList" :key="item.value" :label="item.label" :value="item.value" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="地址" class="wid100">
  20. <el-row style="width:100%">
  21. <el-col :span="8">
  22. <el-form-item label="" prop="sellCountryName" label-width="0px" class="margin-b-0 wid100">
  23. <el-input v-model="formData.data.sellCountryName" placeholder="请输入国家" />
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="" prop="sellProvinceName" label-width="0px" class="margin-b-0 wid100">
  28. <el-input v-model="formData.data.sellProvinceName" placeholder="请输入省/州" />
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8">
  32. <el-form-item label="" prop="sellCityName" label-width="0px" class="margin-b-0 wid100">
  33. <el-input v-model="formData.data.sellCityName" placeholder="请输入城市" />
  34. </el-form-item>
  35. </el-col>
  36. </el-row>
  37. </el-form-item>
  38. <el-form-item label="详细地址" prop="sellAddress" class="wid100">
  39. <el-input v-model="formData.data.sellAddress" type="textarea">
  40. </el-input>
  41. </el-form-item>
  42. <el-form-item label="联系人" class="wid100">
  43. <el-row style="width:100%">
  44. <el-col :span="8">
  45. <el-form-item label="" prop="sellContactName" label-width="0px" class="margin-b-0 wid100">
  46. <el-input v-model="formData.data.sellContactName" placeholder="请输入联系人" />
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="16">
  50. <el-form-item label="" prop="sellContactNumber" label-width="0px" class="margin-b-0 wid100">
  51. <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. </el-form-item>
  56. </div>
  57. </template>
  58. <template #buyer>
  59. <div style="width: 100%">
  60. <el-form-item label="买方信息" prop="buyCorporationId" class="wid100">
  61. <el-select v-model="formData.data.buyCorporationId" filterable remote reserve-keyword placeholder="请输入关键字" remote-show-suffix
  62. :remote-method="remoteMethod" :loading="loadingSearch" @input="remoteMethod" style="width: 100%" @change="changeCustomer" v-if="
  63. [30].includes(route.query.processType) ||
  64. !route.query.processType
  65. " :disabled="!isEditList">
  66. <el-option v-for="item in customerList" :key="item.value" :label="item.label" :value="item.value" />
  67. </el-select>
  68. <el-select v-model="formData.data.buyCorporationName" disabled v-else style="width: 100%">
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item label="地址" class="wid100" required>
  72. <el-row style="width: 100%">
  73. <el-col :span="6">
  74. <el-form-item label="" prop="countryId" class="margin-b-0">
  75. <el-select v-model="formData.data.countryId" placeholder="国家" style="width:100%" filterable
  76. @change="(val) => getCityData(val, '20', true)" :disabled="!isEditList">
  77. <el-option v-for="item in countryData" :label="item.name" :value="item.id">
  78. </el-option>
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="6">
  83. <el-form-item label="" prop="provinceName" class="margin-b-0">
  84. <selectCity placeholder="省/洲" @change="(val) => getCityData(val, '30', true)" addressId="provinceId" addressName="provinceName"
  85. v-model="formData.data" :data="provinceData" :disabled="!isEditList">
  86. </selectCity>
  87. </el-form-item>
  88. </el-col>
  89. <el-col :span="6">
  90. <el-form-item label="" prop="cityName" class="margin-b-0">
  91. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData"
  92. :disabled="!isEditList">
  93. </selectCity>
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="6">
  97. <el-form-item label="" prop="buyPostalCode" class="margin-b-0">
  98. <el-input v-model="formData.data.buyPostalCode" placeholder="请输入邮编" :disabled="!isEditList" />
  99. </el-form-item>
  100. </el-col>
  101. </el-row>
  102. </el-form-item>
  103. <el-form-item label="详细地址" prop="buyAddress" class="wid100">
  104. <el-input v-model="formData.data.buyAddress" type="textarea" :disabled="!isEditList">
  105. </el-input>
  106. </el-form-item>
  107. <el-form-item label="联系人" class="wid100" required>
  108. <el-row style="width: 100%">
  109. <el-col :span="8">
  110. <el-form-item label="" prop="buyContactName" label-width="0px" class="margin-b-0 wid100">
  111. <el-autocomplete v-model="formData.data.buyContactName" :fetch-suggestions="querySearchPerson" style="width:100%" clearable
  112. class="inline-input w-50" placeholder="请输入联系人" @select="handlePerson" :disabled="!isEditList">
  113. </el-autocomplete>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="16">
  117. <el-form-item label="" prop="buyContactNumber" label-width="0px" class="margin-b-0 wid100">
  118. <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" :disabled="!isEditList" />
  119. </el-form-item>
  120. </el-col>
  121. </el-row>
  122. </el-form-item>
  123. </div>
  124. </template>
  125. <template #commodity>
  126. <div style="width: 100%">
  127. <el-button type="primary" @click="openProductCompany = true" plain style="margin-bottom: 16px"
  128. v-if="!judgeStatus() && isEditList">产品库</el-button>
  129. <!-- default-expand-all -->
  130. <el-table :data="formData.data.contractProductList" style="width: 100%; " default-expand-all>
  131. <el-table-column type="expand" width="50" align="center">
  132. <template #default="scope">
  133. <div style="padding-left:50px">
  134. <div style="margin-bottom:10px;">
  135. <TitleInfo content='BOM单:'></TitleInfo>
  136. </div>
  137. <el-table :data="scope.row.contractProductBomList" style="width: 100%;" border class="bom-table">
  138. <el-table-column label="图片" width="80">
  139. <template #default="{ row }">
  140. <div v-if="row.fileUrl">
  141. <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  142. </div>
  143. <div v-else></div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column prop="productCode" label="物料编码" width="190" />
  147. <el-table-column prop="productName" label="物料名称" min-width="200" />
  148. <el-table-column label="尺寸 (cm)" width="150">
  149. <template #default="{ row, $index }">
  150. <div style="width: 100%">
  151. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  152. </div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="quantity" label="数量" width="130">
  156. <template #default="{ row, $index }">
  157. <div style="width: 100%">
  158. <el-form-item v-if="isEditList"
  159. :prop="'contractProductList.' + scope.$index + '.contractProductBomList.' + $index + '.quantity'"
  160. :rules="rules.quantity" :inline-message="true" class="margin-b-0 wid100">
  161. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  162. :controls="false" :min="1" />
  163. </el-form-item>
  164. <span v-else>{{row.quantity}}</span>
  165. </div>
  166. </template>
  167. </el-table-column>
  168. <!-- <el-table-column prop="allQuantity" label="总量" width="80" /> -->
  169. <!-- <el-table-column prop="price" label="单价" width="110">
  170. <template #default="{ row, $index }">
  171. <div style="width: 100%">
  172. {{row.price}}
  173. </div>
  174. </template>
  175. </el-table-column> -->
  176. <!-- <el-table-column prop="amount" label="小计" width="110">
  177. <template #default="{ row, $index }">
  178. <div style="width: 100%">
  179. {{row.amount}}
  180. </div>
  181. </template>
  182. </el-table-column> -->
  183. <el-table-column prop="remark" label="备注" width="180">
  184. <template #default="{ row, $index }">
  185. <div style="width: 100%">
  186. <el-form-item v-if="isEditList" :inline-message="true" class="margin-b-0 wid100">
  187. <el-input v-model="row.remark" placeholder="请输入" style="width: 100%" />
  188. </el-form-item>
  189. <span v-else>{{row.remark}}</span>
  190. </div>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="操作" width="60" align="center" fixed="right" v-if="isEditList">
  194. <template #default="{ row,$index }">
  195. <el-button type="primary" link @click="handleDeleteMaterial(scope.$index,$index)">删除</el-button>
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. </div>
  200. </template>
  201. </el-table-column>
  202. <el-table-column label="商品图片" width="80">
  203. <template #default="{ row }">
  204. <div v-if="row.fileUrl">
  205. <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
  206. </div>
  207. <div v-else></div>
  208. </template>
  209. </el-table-column>
  210. <el-table-column prop="productCnName" label="商品名称" min-width="130" />
  211. <el-table-column prop="productCode" label="商品编码" width="130" />
  212. <el-table-column label="尺寸 cm*cm*cm" width="180">
  213. <template #default="{ row, $index }">
  214. <div style="width: 100%">
  215. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  216. </div>
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="设计图稿" width="80">
  220. <template #default="{ row, $index }">
  221. <div style="width: 100%">
  222. <el-upload action="https://winfaster.obs.cn-south-1.myhuaweicloud.com" accept=".gif, .jpeg, .jpg, .png" :show-file-list="false"
  223. :data="uploadData" :before-upload="(file)=>handleBeforeUpload(file,$index)" :on-success="()=>handleSuccess($index)">
  224. <div v-loading="row.imgLoading">
  225. <img v-if="row.imageUrl" :src="row.imageUrl" class="pic" />
  226. <el-icon v-else class="avatar-uploader-icon">
  227. <Plus />
  228. </el-icon>
  229. </div>
  230. </el-upload>
  231. </div>
  232. </template>
  233. </el-table-column>
  234. <el-table-column label="生产源文件" width="140">
  235. <template #default="{ row, $index }">
  236. <!-- <span class="el-click" v-if="!row.prodFilePath" @click="handleClickUpload('prodFilePath',false)">点击</span> -->
  237. <span class="el-click" v-if="row.prodFilePath" @click="handleClickUpload('prodFilePath',false,$index)">点击上传 (查看)</span>
  238. <el-button type="primary" link @click="handleClickUpload('prodFilePath',true,$index)" v-else>定制图稿</el-button>
  239. </template>
  240. </el-table-column>
  241. <el-table-column label="数量" width="150">
  242. <template #default="{ row, $index }">
  243. <div style="width: 100%">
  244. <el-form-item :prop="'contractProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true"
  245. class="margin-b-0 wid100">
  246. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  247. :controls="false" :min="0" @change="calculationAmount('quantity')" v-if="isEditList" />
  248. <div v-else> {{row.quantity}}</div>
  249. </el-form-item>
  250. </div>
  251. </template>
  252. </el-table-column>
  253. <el-table-column label="单价" width="180">
  254. <template #default="{ row, $index }">
  255. <div style="width: 100%">
  256. <el-form-item :prop="'contractProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true"
  257. class="margin-b-0 wid100">
  258. <div style="display:flex;">
  259. <el-input-number onmousewheel="return false;" v-model="row.price" placeholder="请输入" style="width: 100%" :precision="2"
  260. :controls="false" :min="0" @change="calculationAmount()" v-if="isEditList" />
  261. <div v-else>{{row.price}}</div>
  262. <el-popover placement="top-start" :width="400" trigger="hover" @show="showEcharts(row,$index)">
  263. <template #default>
  264. <div>
  265. <div>
  266. <img src="@/assets/images/money1.png" alt="" class="img" /> <span
  267. style="font-size:14px;font-weight:700;color:#000">销售指导价:</span>
  268. <div style="padding:5px 0px 0px 20px">
  269. {{row.currency}} {{moneyFormat(row.salePrice,2)}}
  270. </div>
  271. </div>
  272. <div style="margin-top:15px">
  273. <img src="@/assets/images/money2.png" alt="" class="img" /> <span
  274. style="font-size:14px;font-weight:700;color:#000">客户近期购买价格:</span>
  275. <div style="padding:5px 0px 0px 20px">
  276. <div v-for="item in row.customerContractProductList">
  277. <span>{{item.createTime.slice(0,10)}} </span>
  278. <span style="margin-left:40px">{{item.code}} </span>
  279. <span style="margin-left:40px"> {{item.currency}} {{moneyFormat(item.price,2)}} </span>
  280. </div>
  281. </div>
  282. </div>
  283. <div style="margin-top:15px">
  284. <img src="@/assets/images/money3.png" alt="" class="img" /> <span
  285. style="font-size:14px;font-weight:700;color:#000">产品近期销售价格:</span>
  286. <div style="padding:5px 0px 0px 20px">
  287. <div v-for="item in row.contractProductList">
  288. <span>{{item.createTime.slice(0,10)}} </span>
  289. <span style="margin-left:40px">{{item.code}} </span>
  290. <span style="margin-left:40px">{{item.currency}} {{moneyFormat(item.price,2)}} </span>
  291. </div>
  292. </div>
  293. </div>
  294. <div :ref="row.productId+$index" style="height:180px">
  295. </div>
  296. </div>
  297. </template>
  298. <template #reference>
  299. <div style="margin-left:10px;cursor:pointer;position:relative;top:4px">
  300. <el-icon :size="20" color="#85c1a6">
  301. <WarningFilled />
  302. </el-icon>
  303. </div>
  304. </template>
  305. </el-popover>
  306. </div>
  307. </el-form-item>
  308. </div>
  309. </template>
  310. </el-table-column>
  311. <el-table-column prop="amount" label="小计" width="110">
  312. <template #default="{ row, $index }">
  313. <div style="width: 100%">
  314. {{row.amount}}
  315. </div>
  316. </template>
  317. </el-table-column>
  318. <el-table-column label="备注" min-width="200">
  319. <template #default="{ row, $index }">
  320. <div style="width: 100%">
  321. <el-form-item :prop="'contractProductList.' + $index + '.remark'" :inline-message="true" class="margin-b-0 wid100">
  322. <el-input v-model="row.remark" placeholder="请输入" style="width: 100%" />
  323. </el-form-item>
  324. </div>
  325. </template>
  326. </el-table-column>
  327. <el-table-column label="操作" width="140" align="center" fixed="right" v-if="!judgeStatus() && isEditList">
  328. <template #default="{ $index }">
  329. <el-button type="primary" link @click="handleClickSelectMaterial($index)">包材辅材</el-button>
  330. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  331. </template>
  332. </el-table-column>
  333. </el-table>
  334. </div>
  335. </template>
  336. <template #otherCharge>
  337. <div style="width: 100%">
  338. <el-button type="primary" @click="clickAdd()" plain style="margin-bottom: 16px" v-if="!judgeStatus()">添加行</el-button>
  339. <el-table :data="formData.data.contractProjectList" style="width: 100%;">
  340. <el-table-column label="收费项目" width="220">
  341. <template #default="{ row, $index }">
  342. <div style="width: 100%">
  343. <el-form-item :prop="'contractProjectList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true"
  344. class="margin-b-0 wid100">
  345. <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50"
  346. placeholder="请输入收费项目" />
  347. </el-form-item>
  348. </div>
  349. </template>
  350. </el-table-column>
  351. <el-table-column :label="'金额'" width="130">
  352. <template #default="{ row, $index }">
  353. <div style="width: 100%">
  354. <el-form-item :prop="'contractProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true"
  355. class="margin-b-0 wid100">
  356. <el-input-number onmousewheel="return false;" v-model="row.amount" placeholder="请输入金额" style="width: 100%" :precision="2"
  357. :controls="false" :min="0" @change="totalAmount()" />
  358. </el-form-item>
  359. </div>
  360. </template>
  361. </el-table-column>
  362. <el-table-column label="备注">
  363. <template #default="{ row, $index }">
  364. <div style="width: 100%">
  365. <el-form-item :prop="'contractProjectList.' + $index + '.remark'" class="margin-b-0 wid100">
  366. <el-input v-model="row.remark" placeholder="请输入备注" />
  367. </el-form-item>
  368. </div>
  369. </template>
  370. </el-table-column>
  371. <el-table-column label="操作" width="60" align="center" fixed="right" v-if="!judgeStatus()">
  372. <template #default="{ $index }">
  373. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  374. </template>
  375. </el-table-column>
  376. </el-table>
  377. </div>
  378. </template>
  379. <template #templateContent>
  380. <div style="width: 100%">
  381. <Editor :value="formData.data.templateContent" @updateValue="updateContent" :readOnly="judgeStatus()" ref="remarkEditor" />
  382. </div>
  383. </template>
  384. </byForm>
  385. <el-dialog v-if="openProductCompany" v-model="openProductCompany" title="产品库" width="90%" append-to-body>
  386. <SelectProduct @selectProduct="selectProduct" :companyId="formData.data.companyId" :isRawMaterial="'1'"></SelectProduct>
  387. <template #footer>
  388. <el-button @click="openProductCompany = false" size="defualt" v-debounce>关 闭</el-button>
  389. </template>
  390. </el-dialog>
  391. <el-dialog :title="'物料选择'" v-model="openSelectMaterial" width="90%" destroy-on-close>
  392. <SelectMaterial :isNeRawMaterial="'1'" @selectMaterial="selectMaterial"></SelectMaterial>
  393. <template #footer>
  394. <el-button @click="openSelectMaterial = false" size="defualt" v-debounce>关 闭</el-button>
  395. </template>
  396. </el-dialog>
  397. <!-- <el-dialog v-if="copyContract" v-model="copyContract" :title="copyType === 1 ? '合同选择' : '样品单选择'" width="90%" append-to-body>
  398. <SelectContract @select="selectContract" v-if="copyType === 1"></SelectContract>
  399. <SelectSample @select="selectContract" v-if="copyType === 2"></SelectSample>
  400. </el-dialog> -->
  401. </div>
  402. </template>
  403. <script setup>
  404. import byForm from "@/components/byForm/index";
  405. import SelectProduct from "@/components/product/SelectProduct.vue";
  406. import SelectMaterial from "@/components/product/SelectMaterial.vue";
  407. import Editor from "@/components/Editor/index.vue";
  408. import selectCity from "@/components/selectCity/index.vue";
  409. import { useRoute } from "vue-router";
  410. import SelectContract from "@/components/contractCom/selectContract.vue";
  411. import SelectSample from "@/components/contractCom/selectSample.vue";
  412. import * as echarts from "echarts";
  413. import $bus from "@/bus/index.js";
  414. const route = useRoute();
  415. const { proxy } = getCurrentInstance();
  416. // 接收父组件的传值
  417. const props = defineProps({
  418. queryData: Object,
  419. });
  420. const currencyData = computed(
  421. () => proxy.useUserStore().allDict["account_currency"]
  422. );
  423. const fundsPaymentMethod = computed(
  424. () => proxy.useUserStore().allDict["funds_payment_method"]
  425. );
  426. const shippingMethod = computed(
  427. () => proxy.useUserStore().allDict["shipping_method"]
  428. );
  429. const companyId = computed(() => proxy.useUserStore().user.companyId);
  430. const accountList = ref([]);
  431. const customerList = ref([]);
  432. const templateList = ref([]);
  433. const corporationList = ref([]);
  434. const customerUserList = ref([]);
  435. const countryData = ref([]);
  436. const provinceData = ref([]);
  437. const cityData = ref([]);
  438. const treeData = ref([]);
  439. const openProductCompany = ref(false);
  440. const copyType = ref(1);
  441. const copyContract = ref(false);
  442. const indexValue = ref(-1);
  443. const openSelectMaterial = ref(false);
  444. const formData = reactive({
  445. data: {
  446. contractType: "2",
  447. rate: 1,
  448. contractProductList: [],
  449. companyId: companyId.value,
  450. templateContent: "",
  451. },
  452. });
  453. const uploadData = ref({});
  454. const formDom = ref(null);
  455. const remarkEditor = ref(null);
  456. const judgeStatus = () => {
  457. if (
  458. route.query.processType == 20 ||
  459. route.query.processType == 10 ||
  460. props.queryData.processType == 20 ||
  461. props.queryData.processType == 10
  462. ) {
  463. return true;
  464. }
  465. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  466. let data = props.queryData.recordList.filter(
  467. (item) => item.status === 2 && item.nodeType !== 1
  468. );
  469. if (data && data.length > 0) {
  470. return true;
  471. }
  472. }
  473. return false;
  474. };
  475. const formOption = reactive({
  476. inline: true,
  477. labelWidth: 120,
  478. itemWidth: 100,
  479. disabled: false,
  480. });
  481. const formConfig = computed(() => {
  482. return [
  483. // {
  484. // type: "slot",
  485. // slotName: "btn",
  486. // label: "",
  487. // itemWidth: 50,
  488. // },
  489. {
  490. type: "title",
  491. title: "基本信息",
  492. },
  493. {
  494. type: "input",
  495. prop: "code",
  496. label: "合同号",
  497. disabled: true,
  498. isShow: formData.data.code ? true : false,
  499. },
  500. {
  501. type: "select",
  502. prop: "contractType",
  503. label: "合同类型",
  504. data: [
  505. {
  506. dictKey: "2",
  507. dictValue: "内销",
  508. },
  509. {
  510. dictKey: "1",
  511. dictValue: "外销",
  512. },
  513. ],
  514. itemWidth: 50,
  515. fn: (val) => {
  516. if (val == "2") {
  517. formData.data.currency = currencyData.value[0].dictKey;
  518. formData.data.rate = 1;
  519. }
  520. if (formData.data.sellCorporationId) {
  521. sellCorporationIdChange(formData.data.sellCorporationId);
  522. }
  523. if (formData.data.shroffAccountId) {
  524. changeShroffAccount(formData.data.shroffAccountId);
  525. }
  526. },
  527. },
  528. {
  529. type: "treeSelect",
  530. prop: "companyId",
  531. label: "生产公司",
  532. data: treeData.value,
  533. propsTreeLabel: "deptName",
  534. propsTreeValue: "deptId",
  535. itemWidth: 50,
  536. disabled: companyId.value != "100" || !isEditList.value,
  537. fn: () => {
  538. formData.data.contractProductList = [];
  539. },
  540. },
  541. {
  542. type: "title",
  543. title: "贸易信息",
  544. haveLine: true,
  545. },
  546. {
  547. type: "slot",
  548. slotName: "seller",
  549. label: "",
  550. itemWidth: 50,
  551. },
  552. {
  553. type: "slot",
  554. slotName: "buyer",
  555. label: "",
  556. itemWidth: 50,
  557. },
  558. {
  559. type: "title",
  560. title: "付款信息",
  561. haveLine: true,
  562. },
  563. {
  564. type: "select",
  565. prop: "currency",
  566. label: "币种",
  567. data: currencyData.value,
  568. itemWidth: 25,
  569. disabled: formData.data.contractType == "2",
  570. },
  571. {
  572. type: "number",
  573. prop: "rate",
  574. label: "汇率",
  575. precision: 2,
  576. min: 0,
  577. controls: false,
  578. itemWidth: 25,
  579. disabled: formData.data.contractType == "2",
  580. },
  581. {
  582. type: "select",
  583. prop: "paymentMethod",
  584. label: "付款方式",
  585. data: fundsPaymentMethod.value,
  586. itemWidth: 25,
  587. },
  588. {
  589. type: "number",
  590. prop: "advanceRatio",
  591. label: "预付款比列(%)",
  592. precision: 2,
  593. min: 0,
  594. controls: false,
  595. itemWidth: 25,
  596. },
  597. {
  598. type: "input",
  599. prop: "remark",
  600. label: "付款条件",
  601. itemType: "textarea",
  602. itemWidth: 50,
  603. },
  604. {
  605. type: "select",
  606. prop: "shroffAccountId",
  607. label: "收款账号",
  608. data: accountList.value,
  609. itemWidth: 100,
  610. fn: (val) => {
  611. changeShroffAccount(val);
  612. },
  613. },
  614. {
  615. type: "input",
  616. prop: "beneficiaryName",
  617. label: " ",
  618. placeholder: "请输入Beneficiary Name",
  619. itemWidth: 50,
  620. isShow: formData.data.contractType == "1",
  621. },
  622. {
  623. type: "input",
  624. prop: "beneficiaryAccountNumber",
  625. label: " ",
  626. placeholder: "请输入Beneficiary Account Number",
  627. itemWidth: 50,
  628. isShow: formData.data.contractType == "1",
  629. },
  630. {
  631. type: "input",
  632. prop: "beneficiaryBank",
  633. label: " ",
  634. placeholder: "请输入Beneficiary Bank",
  635. itemWidth: 50,
  636. isShow: formData.data.contractType == "1",
  637. },
  638. {
  639. type: "input",
  640. prop: "swiftCode",
  641. label: " ",
  642. placeholder: "请输入Swift Code",
  643. itemWidth: 50,
  644. isShow: formData.data.contractType == "1",
  645. },
  646. {
  647. type: "input",
  648. prop: "beneficiaryBankAddress",
  649. label: " ",
  650. placeholder: "请输入Beneficiary Bank Address",
  651. itemWidth: 50,
  652. isShow: formData.data.contractType == "1",
  653. },
  654. {
  655. type: "input",
  656. prop: "beneficiaryAddress",
  657. label: " ",
  658. placeholder: "请输入Beneficiary Address",
  659. itemWidth: 50,
  660. isShow: formData.data.contractType == "1",
  661. },
  662. {
  663. type: "input",
  664. prop: "accountName",
  665. label: "户名",
  666. placeholder: "请输入户名",
  667. itemWidth: 50,
  668. isShow: formData.data.contractType == "2",
  669. },
  670. {
  671. type: "input",
  672. prop: "openingBank",
  673. label: "开户行",
  674. placeholder: "请输入开户行",
  675. itemWidth: 50,
  676. isShow: formData.data.contractType == "2",
  677. },
  678. {
  679. type: "input",
  680. prop: "accountOpening",
  681. label: "账号",
  682. placeholder: "请输入账号",
  683. itemWidth: 50,
  684. isShow: formData.data.contractType == "2",
  685. },
  686. // {
  687. // type: "slot",
  688. // slotName: "payment",
  689. // label: "",
  690. // },
  691. {
  692. type: "title",
  693. title: "交付信息",
  694. haveLine: true,
  695. },
  696. {
  697. type: "date",
  698. prop: "deliveryTime",
  699. label: "交货期限",
  700. itemWidth: 50,
  701. },
  702. {
  703. type: "select",
  704. prop: "transportMethod",
  705. label: "运输方式",
  706. data: shippingMethod.value,
  707. itemWidth: 50,
  708. },
  709. {
  710. type: "input",
  711. prop: "transportRemark",
  712. label: "运输说明",
  713. itemWidth: 50,
  714. },
  715. // {
  716. // type: "slot",
  717. // slotName: "delivery",
  718. // label: "",
  719. // },
  720. {
  721. type: "title",
  722. title: "商品信息",
  723. haveLine: true,
  724. },
  725. {
  726. type: "slot",
  727. slotName: "commodity",
  728. label: "",
  729. },
  730. {
  731. type: "title",
  732. title: "其他收费项目",
  733. haveLine: true,
  734. },
  735. {
  736. type: "slot",
  737. slotName: "otherCharge",
  738. label: "",
  739. },
  740. {
  741. type: "title",
  742. title: "合同总金额",
  743. haveLine: true,
  744. },
  745. {
  746. type: "input",
  747. prop: "amount",
  748. label: "合同总金额",
  749. itemWidth: 25,
  750. disabled: true,
  751. },
  752. {
  753. type: "title",
  754. title: "合同模板",
  755. haveLine: true,
  756. },
  757. {
  758. type: "select",
  759. prop: "contractTemplateId",
  760. label: "合同模板",
  761. data: templateList.value,
  762. itemWidth: 50,
  763. fn: (val) => {
  764. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  765. formData.data.templateContent = res.templateContent;
  766. remarkEditor.value.changeHtml(formData.data.templateContent);
  767. });
  768. },
  769. },
  770. {
  771. type: "slot",
  772. slotName: "templateContent",
  773. prop: "templateContent",
  774. label: "模板内容",
  775. itemWidth: 100,
  776. disabled: false,
  777. },
  778. ];
  779. });
  780. const rules = ref({
  781. companyId: [{ required: true, message: "请选择生产公司", trigger: "change" }],
  782. contractType: [
  783. { required: true, message: "请选择合同类型", trigger: "change" },
  784. ],
  785. sellCorporationId: [
  786. { required: true, message: "请选择卖方公司", trigger: "change" },
  787. ],
  788. buyCorporationId: [
  789. { required: true, message: "请选择买方公司", trigger: "change" },
  790. ],
  791. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  792. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  793. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  794. buyContactName: [
  795. { required: true, message: "请输入联系人", trigger: ["change", "blur"] },
  796. ],
  797. buyContactNumber: [
  798. { required: true, message: "请输入联系电话", trigger: "blur" },
  799. ],
  800. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  801. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  802. payName: [
  803. { required: true, message: "请输入收费项目", trigger: ["change", "blur"] },
  804. ],
  805. currency: [{ required: true, message: "请选择币种", trigger: "change" }],
  806. paymentMethod: [
  807. { required: true, message: "请选择付款方式", trigger: "change" },
  808. ],
  809. advanceRatio: [
  810. { required: true, message: "请输入预付比例", trigger: "blur" },
  811. ],
  812. transportMethod: [
  813. { required: true, message: "请选择运输方式", trigger: "change" },
  814. ],
  815. // remark: [{ required: true, message: "请输入付款条件", trigger: "blur" }],
  816. rate: [{ required: true, message: "请输入汇率", trigger: "blur" }],
  817. shroffAccountId: [
  818. { required: true, message: "请选择收款账号", trigger: "change" },
  819. ],
  820. // contractTemplateId: [
  821. // { required: true, message: "请选择模板", trigger: "change" },
  822. // ],
  823. templateContent: [
  824. { required: true, message: "请输入模板内容", trigger: "blur" },
  825. ],
  826. });
  827. const getDict = () => {
  828. proxy
  829. .post("/contractTemplate/page", {
  830. pageNum: 1,
  831. pageSize: 999,
  832. templateType: "1",
  833. })
  834. .then((res) => {
  835. templateList.value = res.rows.map((x) => ({
  836. label: x.templateName,
  837. value: x.id,
  838. }));
  839. });
  840. proxy
  841. .post("/customer/selPage", {
  842. pageNum: 1,
  843. pageSize: 50,
  844. })
  845. .then((res) => {
  846. customerList.value = res.rows.map((x) => ({
  847. ...x,
  848. label: x.name,
  849. value: x.id,
  850. }));
  851. });
  852. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  853. corporationList.value = res.rows.map((item) => {
  854. return {
  855. ...item,
  856. label: item.name,
  857. value: item.id,
  858. };
  859. });
  860. });
  861. proxy
  862. .post("/accountManagement/page", { pageNum: 1, pageSize: 999 })
  863. .then((res) => {
  864. accountList.value = res.rows.map((item) => {
  865. return {
  866. ...item,
  867. label: item.alias,
  868. value: item.id,
  869. };
  870. });
  871. });
  872. proxy
  873. .get("/tenantDept/list", {
  874. pageNum: 1,
  875. pageSize: 9999,
  876. keyword: "",
  877. tenantId: proxy.useUserStore().user.tenantId,
  878. type: 0,
  879. })
  880. .then((res) => {
  881. treeData.value = proxy.handleTree(res.data, "deptId");
  882. });
  883. };
  884. const getCityData = (id, type, isChange) => {
  885. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  886. if (type === "20") {
  887. provinceData.value = res;
  888. if (isChange) {
  889. formData.data.provinceId = "";
  890. formData.data.provinceName = "";
  891. formData.data.cityId = "";
  892. formData.data.cityName = "";
  893. }
  894. } else if (type === "30") {
  895. cityData.value = res;
  896. if (isChange) {
  897. formData.data.cityId = "";
  898. formData.data.cityName = "";
  899. }
  900. } else {
  901. countryData.value = res;
  902. }
  903. });
  904. };
  905. getDict();
  906. getCityData("0");
  907. const sellCorporationIdChange = (val) => {
  908. if (val) {
  909. proxy.post("/corporation/detail", { id: val }).then((res) => {
  910. if (formData.data.contractType == "2") {
  911. formData.data.sellCountryName = res.countryName;
  912. formData.data.sellProvinceName = res.provinceName;
  913. formData.data.sellCityName = res.cityName;
  914. formData.data.sellAddress = res.address;
  915. } else {
  916. formData.data.sellCountryName = res.countryEnStr;
  917. formData.data.sellProvinceName = res.provinceEnStr;
  918. formData.data.sellCityName = res.cityEnStr;
  919. formData.data.sellAddress = res.addressEn;
  920. }
  921. });
  922. }
  923. };
  924. const changeCustomer = (val) => {
  925. formData.data.contractProductList = [];
  926. if (val) {
  927. proxy.post("/customer/detail", { id: val }).then(
  928. (res) => {
  929. formData.data.buyCorporationName = res.name;
  930. if (res.customerUserList && res.customerUserList.length > 0) {
  931. formData.data.buyContactName = res.customerUserList[0].name;
  932. if (res.customerUserList[0].contactJson) {
  933. let contactJson = JSON.parse(res.customerUserList[0].contactJson);
  934. if (contactJson && contactJson.length > 0) {
  935. formData.data.buyContactNumber = contactJson[0].contactNo;
  936. }
  937. }
  938. customerUserList.value = res.customerUserList.map((item) => {
  939. return {
  940. ...item,
  941. value: item.name,
  942. };
  943. });
  944. }
  945. // 回填客户的账户信息
  946. // formData.data.beneficiaryName = res.beneficiaryName;
  947. // formData.data.beneficiaryBank = res.beneficiaryBank;
  948. // formData.data.beneficiaryBankAddress = res.beneficiaryBankAddress;
  949. // formData.data.beneficiaryAccountNumber = res.beneficiaryAccountNumber;
  950. // formData.data.swiftCode = res.swiftCode;
  951. // formData.data.beneficiaryAddress = res.beneficiaryAddress;
  952. formData.data.countryId = res.countryId;
  953. formData.data.provinceId = res.provinceId;
  954. formData.data.cityId = res.cityId;
  955. formData.data.buyPostalCode = res.zipCode;
  956. formData.data.buyAddress = res.address;
  957. getCityData(formData.data.countryId, "20");
  958. if (formData.data.provinceId) {
  959. getCityData(formData.data.provinceId, "30");
  960. }
  961. },
  962. (err) => {
  963. formData.data.countryId = "";
  964. formData.data.provinceId = "";
  965. formData.data.cityId = "";
  966. formData.data.buyPostalCode = "";
  967. formData.data.buyAddress = "";
  968. }
  969. );
  970. } else {
  971. formData.data.countryId = "";
  972. formData.data.provinceId = "";
  973. formData.data.cityId = "";
  974. formData.data.buyPostalCode = "";
  975. formData.data.buyAddress = "";
  976. }
  977. };
  978. const createFilter = (queryString) => {
  979. return (restaurant) => {
  980. return (
  981. restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
  982. );
  983. };
  984. };
  985. const querySearchPerson = (queryString, callback) => {
  986. const results = queryString
  987. ? customerUserList.value.filter(createFilter(queryString))
  988. : customerUserList.value;
  989. callback(results);
  990. };
  991. const handlePerson = (item) => {
  992. if (item.contactJson) {
  993. let data = JSON.parse(item.contactJson);
  994. formData.data.buyContactNumber = data[0].contactNo;
  995. }
  996. };
  997. const handleClickSelectMaterial = (index) => {
  998. indexValue.value = index;
  999. openSelectMaterial.value = true;
  1000. };
  1001. const contractProductBomList = ref([]);
  1002. const selectProduct = (goods) => {
  1003. if (goods && goods.id) {
  1004. let fileUrl = "";
  1005. if (goods.fileList && goods.fileList.length > 0) {
  1006. fileUrl = goods.fileList[0].fileUrl;
  1007. }
  1008. proxy.post("/productBomInfo/detail", { id: goods.id }).then((res) => {
  1009. if (res.productBomDetailList && res.productBomDetailList.length > 0) {
  1010. contractProductBomList.value = res.productBomDetailList.map((x) => ({
  1011. fileUrl: "",
  1012. materialId: x.materialId,
  1013. productName: x.materialName,
  1014. productCode: x.materialCode,
  1015. productLength: x.materialLength,
  1016. productWidth: x.materialWidth,
  1017. productHeight: x.materialHeight,
  1018. quantity: x.quantity || null,
  1019. allQuantity: "",
  1020. price: x.materialPrice || null,
  1021. amount: "",
  1022. fileList: [],
  1023. type: x.type,
  1024. }));
  1025. formData.data.contractProductList.push({
  1026. fileUrl: fileUrl,
  1027. productId: goods.id,
  1028. productCnName: goods.name,
  1029. productCode: goods.customCode,
  1030. productLength: goods["length"],
  1031. productWidth: goods.width,
  1032. productHeight: goods.height,
  1033. prodFilePath: goods.prodFilePath,
  1034. quantity: null,
  1035. price: goods.price || null,
  1036. amount: "",
  1037. remark: "",
  1038. fileList: [],
  1039. contractProductBomList: contractProductBomList.value,
  1040. });
  1041. proxy.msgTip("添加成功", 1);
  1042. changeProductPrice();
  1043. let ids = contractProductBomList.value.map((x) => x.materialId);
  1044. proxy.getFile(
  1045. ids,
  1046. contractProductBomList.value,
  1047. "materialId",
  1048. "fileList",
  1049. "fileUrl"
  1050. );
  1051. } else {
  1052. return proxy.msgTip("该产品未配置BOM", 2);
  1053. }
  1054. });
  1055. } else {
  1056. return proxy.msgTip("选择错误", 2);
  1057. }
  1058. };
  1059. const selectMaterial = (goods) => {
  1060. let flag = formData.data.contractProductList[
  1061. indexValue.value
  1062. ].contractProductBomList.some((x) => x.materialId == goods.id);
  1063. if (!flag) {
  1064. let fileUrl = "";
  1065. if (goods.fileList && goods.fileList.length > 0) {
  1066. fileUrl = goods.fileList[0].fileUrl;
  1067. }
  1068. formData.data.contractProductList[
  1069. indexValue.value
  1070. ].contractProductBomList.push({
  1071. fileUrl: fileUrl,
  1072. materialId: goods.id,
  1073. productName: goods.name,
  1074. productCode: goods.customCode,
  1075. productLength: goods["length"],
  1076. productWidth: goods.width,
  1077. productHeight: goods.height,
  1078. quantity: null,
  1079. price: goods.price || null,
  1080. amount: "",
  1081. fileList: [],
  1082. type: 2,
  1083. });
  1084. proxy.msgTip("选择成功");
  1085. } else {
  1086. proxy.msgTip("该物料已选择", 2);
  1087. }
  1088. };
  1089. const changeProductPrice = () => {
  1090. let productIds = formData.data.contractProductList.map((x) => x.productId);
  1091. if (productIds && productIds.length > 0) {
  1092. proxy
  1093. .post("/contract/getProductPriceInfo", {
  1094. productIds: productIds,
  1095. customerId: formData.data.buyCorporationId
  1096. ? formData.data.buyCorporationId
  1097. : "",
  1098. })
  1099. .then((res) => {
  1100. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1101. const iele = formData.data.contractProductList[i];
  1102. for (const key in res) {
  1103. if (key == iele.productId) {
  1104. iele.salePrice = res[key].price;
  1105. iele.currency = res[key].currency;
  1106. iele.saleCostPrice = res[key].costPrice;
  1107. iele.contractProductList = res[key].contractProductList
  1108. .map((x) => ({
  1109. createTime: x.createTime || "",
  1110. price: x.price,
  1111. currency: x.currency,
  1112. }))
  1113. .filter((y, index) => index < 3);
  1114. iele.contractProductListOne = res[key].contractProductList.map(
  1115. (x) => ({
  1116. createTime: x.createTime || "",
  1117. price: x.price,
  1118. currency: x.currency,
  1119. })
  1120. );
  1121. iele.customerContractProductList = res[
  1122. key
  1123. ].customerContractProductList.map((x) => ({
  1124. createTime: x.createTime || "",
  1125. price: x.price,
  1126. currency: x.currency,
  1127. }));
  1128. }
  1129. }
  1130. }
  1131. });
  1132. }
  1133. };
  1134. const updateContent = (val) => {
  1135. formData.data.templateContent = val;
  1136. };
  1137. const onPicture = (path) => {
  1138. window.open(path, "_blank");
  1139. };
  1140. const handleRemove = (index) => {
  1141. formData.data.contractProductList.splice(index, 1);
  1142. totalAmount();
  1143. };
  1144. const handleDeleteMaterial = (index, sonIndex) => {
  1145. formData.data.contractProductList[index].contractProductBomList.splice(
  1146. sonIndex,
  1147. 1
  1148. );
  1149. };
  1150. const calculationAmount = (att = "") => {
  1151. nextTick(() => {
  1152. if (
  1153. formData.data.contractProductList &&
  1154. formData.data.contractProductList.length > 0
  1155. ) {
  1156. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1157. let money = 0;
  1158. money = parseFloat(
  1159. Number(formData.data.contractProductList[i].quantity) *
  1160. Number(formData.data.contractProductList[i].price)
  1161. ).toFixed(2);
  1162. formData.data.contractProductList[i].amount = money;
  1163. }
  1164. }
  1165. nextTick(() => {
  1166. totalAmount();
  1167. });
  1168. });
  1169. };
  1170. const totalAmount = () => {
  1171. let money = 0;
  1172. if (
  1173. formData.data.contractProductList &&
  1174. formData.data.contractProductList.length > 0
  1175. ) {
  1176. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1177. if (formData.data.contractProductList[i].amount) {
  1178. money = parseFloat(
  1179. Number(money) + Number(formData.data.contractProductList[i].amount)
  1180. ).toFixed(2);
  1181. }
  1182. }
  1183. }
  1184. if (
  1185. formData.data.contractProjectList &&
  1186. formData.data.contractProjectList.length > 0
  1187. ) {
  1188. for (let i = 0; i < formData.data.contractProjectList.length; i++) {
  1189. if (formData.data.contractProjectList[i].amount) {
  1190. money = parseFloat(
  1191. Number(money) + Number(formData.data.contractProjectList[i].amount)
  1192. ).toFixed(2);
  1193. }
  1194. }
  1195. }
  1196. formData.data.amount = money;
  1197. };
  1198. const clickAdd = () => {
  1199. if (
  1200. formData.data.contractProjectList &&
  1201. formData.data.contractProjectList.length > 0
  1202. ) {
  1203. formData.data.contractProjectList.push({
  1204. payName: "",
  1205. amount: null,
  1206. remark: "",
  1207. });
  1208. } else {
  1209. formData.data.contractProjectList = [
  1210. { payName: "", amount: null, remark: "" },
  1211. ];
  1212. }
  1213. };
  1214. const handleDelete = (index) => {
  1215. formData.data.contractProjectList.splice(index, 1);
  1216. totalAmount();
  1217. };
  1218. const querySearch = (queryString, callback) => {
  1219. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  1220. if (res.rows && res.rows.length > 0) {
  1221. res.rows = res.rows.map((item) => {
  1222. return {
  1223. ...item,
  1224. value: item.payName,
  1225. };
  1226. });
  1227. callback(res.rows);
  1228. } else {
  1229. callback([]);
  1230. }
  1231. });
  1232. };
  1233. const handleBeforeUpload = async (file, index) => {
  1234. formData.data.contractProductList[index].imgLoading = true;
  1235. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1236. uploadData.value = res.uploadBody;
  1237. formData.data.contractProductList[index].fileList = [
  1238. {
  1239. id: res.id,
  1240. fileName: res.fileName,
  1241. fileUrl: res.fileUrl,
  1242. uploadState: false,
  1243. },
  1244. ];
  1245. formData.data.contractProductList[index].fileData = res;
  1246. return true;
  1247. };
  1248. const handleSuccess = (index) => {
  1249. if (
  1250. formData.data.contractProductList[index].fileData &&
  1251. formData.data.contractProductList[index].fileData.fileUrl
  1252. ) {
  1253. formData.data.contractProductList[index].uploadState = true;
  1254. formData.data.contractProductList[index].imageUrl =
  1255. formData.data.contractProductList[index].fileData.fileUrl;
  1256. }
  1257. setTimeout(() => {
  1258. formData.data.contractProductList[index].imgLoading = false;
  1259. }, 400);
  1260. };
  1261. const loadingSearch = ref(false);
  1262. const remoteMethod = (keyword) => {
  1263. if (keyword && typeof keyword === "string") {
  1264. loadingSearch.value = true;
  1265. proxy.post("/customer/selPage", { keyword }).then((res) => {
  1266. customerList.value = res.rows.map((x) => ({
  1267. ...x,
  1268. label: x.name,
  1269. value: x.id,
  1270. }));
  1271. loadingSearch.value = false;
  1272. });
  1273. }
  1274. return;
  1275. };
  1276. const handleSubmit = async () => {
  1277. let flag = await formDom.value.handleSubmit(() => {});
  1278. if (flag) {
  1279. if (
  1280. formData.data.contractProductList &&
  1281. formData.data.contractProductList.length > 0
  1282. ) {
  1283. return true;
  1284. } else {
  1285. proxy.msgTip("请添加至少一件商品", 2);
  1286. return false;
  1287. }
  1288. } else {
  1289. setTimeout(() => {
  1290. const errorDiv = document.getElementsByClassName("is-error");
  1291. errorDiv[0].scrollIntoView();
  1292. }, 0);
  1293. }
  1294. return flag;
  1295. };
  1296. const getFormData = () => {
  1297. return proxy.deepClone(formData.data);
  1298. };
  1299. // 向父组件暴露
  1300. defineExpose({
  1301. getFormData,
  1302. handleSubmit,
  1303. });
  1304. const changeShroffAccount = (val) => {
  1305. if (val) {
  1306. let data = accountList.value.find((item) => item.value == val);
  1307. if (formData.data.contractType == "2") {
  1308. if (data) {
  1309. formData.data.beneficiaryName = "";
  1310. formData.data.beneficiaryBank = "";
  1311. formData.data.beneficiaryBankAddress = "";
  1312. formData.data.beneficiaryAccountNumber = "";
  1313. formData.data.swiftCode = "";
  1314. formData.data.beneficiaryAddress = "";
  1315. formData.data.accountName = data.name;
  1316. formData.data.openingBank = data.openingBank;
  1317. formData.data.accountOpening = data.accountOpening;
  1318. }
  1319. } else {
  1320. if (data) {
  1321. formData.data.accountName = "";
  1322. formData.data.openingBank = "";
  1323. formData.data.accountOpening = "";
  1324. formData.data.beneficiaryName = data.beneficiaryName;
  1325. formData.data.beneficiaryBank = data.beneficiaryBank;
  1326. formData.data.beneficiaryBankAddress = data.beneficiaryBankAddress;
  1327. formData.data.beneficiaryAccountNumber = data.beneficiaryAccountNumber;
  1328. formData.data.swiftCode = data.swiftCode;
  1329. formData.data.beneficiaryAddress = data.beneficiaryAddress;
  1330. }
  1331. }
  1332. }
  1333. };
  1334. const handleClickUpload = async (att, flag, index) => {
  1335. let res = null;
  1336. let path = "";
  1337. if (flag) {
  1338. proxy.msgTip("请稍后", 2);
  1339. res = await proxy.post("/fileService/createTempFolder");
  1340. if (res && res.path) {
  1341. formData.data.contractProductList[index][att] = res.path;
  1342. path = res.path;
  1343. }
  1344. } else {
  1345. path = formData.data.contractProductList[index][att];
  1346. }
  1347. let a = document.createElement("a");
  1348. a.href = "printer://" + "ftp://121.37.194.75/" + path + "/";
  1349. a.style.display = "none";
  1350. document.body.appendChild(a);
  1351. a.click();
  1352. document.body.removeChild(a);
  1353. };
  1354. const getAllData = (businessId) => {
  1355. proxy.post("/contract/detail", { id: businessId }).then((res) => {
  1356. res.countryId = res.buyCountryId;
  1357. res.provinceId = res.buyProvinceId;
  1358. res.cityId = res.buyCityId;
  1359. if (res.grossProfitInfoList && res.grossProfitInfoList.length > 0) {
  1360. $bus.emit("getGrossData", res.grossProfitInfoList);
  1361. }
  1362. for (const key in res) {
  1363. formData.data[key] = res[key];
  1364. }
  1365. remarkEditor.value.changeHtml(formData.data.templateContent);
  1366. if (
  1367. formData.data.contractProductList &&
  1368. formData.data.contractProductList.length > 0
  1369. ) {
  1370. getFileData();
  1371. let ids = formData.data.contractProductList.map((x) => x.id);
  1372. proxy.getFile(
  1373. ids,
  1374. formData.data.contractProductList,
  1375. "id",
  1376. "fileList",
  1377. "imageUrl"
  1378. );
  1379. changeProductPrice();
  1380. }
  1381. if (formData.data.countryId) {
  1382. getCityData(formData.data.countryId, "20");
  1383. }
  1384. if (formData.data.provinceId) {
  1385. getCityData(formData.data.provinceId, "30");
  1386. }
  1387. });
  1388. };
  1389. const getFileData = () => {
  1390. let ids = [];
  1391. formData.data.contractProductList.map((x) => {
  1392. ids.push(x.productId);
  1393. x.contractProductBomList.map((y) => {
  1394. ids.push(y.materialId);
  1395. });
  1396. });
  1397. ids = Array.from(new Set(ids));
  1398. proxy
  1399. .post("/fileInfo/getList", {
  1400. businessIdList: ids,
  1401. })
  1402. .then((fileObj) => {
  1403. formData.data.contractProductList.map((x) => {
  1404. if (fileObj[x.productId] && fileObj[x.productId].length > 0) {
  1405. x.fileUrl = fileObj[x.productId][0].fileUrl;
  1406. }
  1407. x.contractProductBomList.map((y) => {
  1408. y.fileList = fileObj[y.materialId] || [];
  1409. if (y.fileList && y.fileList.length > 0) {
  1410. y.fileUrl = y.fileList[0].fileUrl;
  1411. }
  1412. });
  1413. });
  1414. });
  1415. };
  1416. const getPriceSheetData = (id) => {
  1417. proxy.post("/extQuotation/detail", { id }).then((res) => {
  1418. formData.data = res;
  1419. formData.data = {
  1420. templateContent: "",
  1421. quotationId: res.id,
  1422. companyId: res.companyId,
  1423. buyCorporationId: res.buyCorporationId,
  1424. buyAddress: res.buyAddress,
  1425. buyPostalCode: res.buyPostalCode,
  1426. buyContactName: res.buyContactName,
  1427. buyContactNumber: res.buyContactNumber,
  1428. amount: res.amount,
  1429. };
  1430. if (res.type == 1) {
  1431. formData.data.contractType = "2";
  1432. if (currencyData.value && currencyData.value.length > 0) {
  1433. formData.data.currency = currencyData.value[0].dictKey;
  1434. }
  1435. formData.data.rate = 1;
  1436. } else {
  1437. formData.data.contractType = "1";
  1438. }
  1439. formData.data.contractProductList = res.quotationProductList.map((x) => ({
  1440. quotationProductId: x.id,
  1441. fileUrl: "",
  1442. productId: x.productId,
  1443. productCnName: x.productName,
  1444. productCode: x.productCode,
  1445. productLength: x.productLength,
  1446. productWidth: x.productWidth,
  1447. productHeight: x.productHeight,
  1448. prodFilePath: x.productProdImgPath,
  1449. quantity: x.quantity,
  1450. price: x.price,
  1451. amount: x.amount,
  1452. fileList: [],
  1453. contractProductBomList: x.quotationProductBomList.map((y) => {
  1454. y.quotationProductBomId = y.id;
  1455. delete y.id;
  1456. return y;
  1457. }),
  1458. }));
  1459. changeProductPrice();
  1460. getFileData();
  1461. formData.data.countryId = res.buyCountryId;
  1462. formData.data.provinceId = res.buyProvinceId;
  1463. formData.data.cityId = res.buyCityId;
  1464. if (formData.data.countryId) {
  1465. getCityData(formData.data.countryId, "20");
  1466. }
  1467. if (formData.data.provinceId) {
  1468. getCityData(formData.data.provinceId, "30");
  1469. }
  1470. });
  1471. };
  1472. // 是否能编辑修改产品列表
  1473. const isEditList = ref(true);
  1474. onMounted(() => {
  1475. if (currencyData.value && currencyData.value.length > 0) {
  1476. formData.data.currency = currencyData.value[0].dictKey;
  1477. }
  1478. formOption.disabled = judgeStatus();
  1479. // 报价转销售订单
  1480. if (route.query && route.query.priceSheetId) {
  1481. getPriceSheetData(route.query.priceSheetId);
  1482. isEditList.value = false;
  1483. } else if (route.query && route.query.businessId && route.query.processType) {
  1484. let businessId = route.query.businessId;
  1485. getAllData(businessId);
  1486. }
  1487. });
  1488. watch(
  1489. () => props.queryData,
  1490. (val) => {
  1491. nextTick(() => {
  1492. formOption.disabled = judgeStatus();
  1493. });
  1494. if (val.businessId && val.processType) {
  1495. getAllData(val.businessId);
  1496. }
  1497. },
  1498. {
  1499. deep: true,
  1500. immediate: true,
  1501. }
  1502. );
  1503. const showPriceInfo = () => {
  1504. if (props.queryData.processType) {
  1505. return false;
  1506. }
  1507. if (route.query.processType) {
  1508. return false;
  1509. } else {
  1510. return true;
  1511. }
  1512. };
  1513. const optionTwo = reactive({
  1514. data: {
  1515. tooltip: {
  1516. trigger: "axis",
  1517. },
  1518. // legend: {
  1519. // data: ["价格"],
  1520. // },
  1521. grid: {
  1522. left: "3%",
  1523. right: "4%",
  1524. top: "10%",
  1525. bottom: "3%",
  1526. containLabel: true,
  1527. },
  1528. // toolbox: {
  1529. // feature: {
  1530. // saveAsImage: {},
  1531. // },
  1532. // },
  1533. xAxis: {
  1534. type: "category",
  1535. boundaryGap: false,
  1536. data: [],
  1537. },
  1538. yAxis: {
  1539. type: "value",
  1540. },
  1541. series: [
  1542. {
  1543. name: "价格",
  1544. type: "line",
  1545. data: [],
  1546. },
  1547. ],
  1548. },
  1549. });
  1550. const showEcharts = (row, index) => {
  1551. let myChart = null;
  1552. myChart = echarts.init(proxy.$refs[row.productId + index]);
  1553. window.addEventListener("resize", () => {
  1554. myChart.resize();
  1555. });
  1556. if (row.contractProductListOne && row.contractProductListOne.length > 0) {
  1557. optionTwo.data.xAxis.data = row.contractProductListOne.map((item) => {
  1558. return item.createTime.slice(0, 10);
  1559. });
  1560. optionTwo.data.series[0].data = row.contractProductListOne.map((item) => {
  1561. return item.price;
  1562. });
  1563. } else {
  1564. optionTwo.data.xAxis.data = [];
  1565. optionTwo.data.series[0].data = [];
  1566. }
  1567. myChart.setOption(optionTwo.data);
  1568. myChart.resize();
  1569. };
  1570. const clickCopy = (type) => {
  1571. copyType.value = type;
  1572. copyContract.value = true;
  1573. };
  1574. </script>
  1575. <style lang="scss" scoped>
  1576. .img {
  1577. object-fit: contain;
  1578. width: 16px;
  1579. height: 16px;
  1580. vertical-align: middle;
  1581. }
  1582. .pic {
  1583. object-fit: contain;
  1584. width: 50px;
  1585. height: 50px;
  1586. cursor: pointer;
  1587. vertical-align: middle;
  1588. }
  1589. .el-icon.avatar-uploader-icon {
  1590. font-size: 20px;
  1591. color: #8c939d;
  1592. width: 50px;
  1593. height: 50px;
  1594. text-align: center;
  1595. border: 1px dashed var(--el-border-color);
  1596. }
  1597. .ql-editor {
  1598. padding: 0px;
  1599. }
  1600. </style>