Contract.vue 71 KB

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