Contract.vue 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055
  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="生产源文件" 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. return true;
  1522. } else {
  1523. proxy.msgTip("请添加至少一件商品", 2);
  1524. return false;
  1525. }
  1526. } else {
  1527. // setTimeout(() => {
  1528. // const errorDiv = document.getElementsByClassName("is-error");
  1529. // errorDiv[0].scrollIntoView();
  1530. // }, 0);
  1531. }
  1532. return flag;
  1533. };
  1534. const getFormData = () => {
  1535. // 赋值类型
  1536. formData.data.type = route.query.flowKey == "sample_flow" ? "1" : "0";
  1537. return proxy.deepClone(formData.data);
  1538. };
  1539. // 向父组件暴露
  1540. defineExpose({
  1541. getFormData,
  1542. handleSubmit,
  1543. });
  1544. const changeShroffAccount = (val) => {
  1545. if (val) {
  1546. let data = accountList.value.find((item) => item.value == val);
  1547. if (data) {
  1548. formData.data.beneficiaryName = "";
  1549. formData.data.beneficiaryBank = "";
  1550. formData.data.beneficiaryBankAddress = "";
  1551. formData.data.beneficiaryAccountNumber = "";
  1552. formData.data.swiftCode = "";
  1553. formData.data.beneficiaryAddress = "";
  1554. formData.data.accountName = data.name;
  1555. formData.data.openingBank = data.openingBank;
  1556. formData.data.accountOpening = data.accountOpening;
  1557. }
  1558. // if (formData.data.contractType == "2") {
  1559. // if (data) {
  1560. // formData.data.beneficiaryName = "";
  1561. // formData.data.beneficiaryBank = "";
  1562. // formData.data.beneficiaryBankAddress = "";
  1563. // formData.data.beneficiaryAccountNumber = "";
  1564. // formData.data.swiftCode = "";
  1565. // formData.data.beneficiaryAddress = "";
  1566. // formData.data.accountName = data.name;
  1567. // formData.data.openingBank = data.openingBank;
  1568. // formData.data.accountOpening = data.accountOpening;
  1569. // }
  1570. // } else {
  1571. // if (data) {
  1572. // formData.data.accountName = "";
  1573. // formData.data.openingBank = "";
  1574. // formData.data.accountOpening = "";
  1575. // formData.data.beneficiaryName = data.beneficiaryName;
  1576. // formData.data.beneficiaryBank = data.beneficiaryBank;
  1577. // formData.data.beneficiaryBankAddress = data.beneficiaryBankAddress;
  1578. // formData.data.beneficiaryAccountNumber = data.beneficiaryAccountNumber;
  1579. // formData.data.swiftCode = data.swiftCode;
  1580. // formData.data.beneficiaryAddress = data.beneficiaryAddress;
  1581. // }
  1582. // }
  1583. }
  1584. };
  1585. const handleClickUpload = async (att, flag, index) => {
  1586. let res = null;
  1587. let path = "";
  1588. if (flag) {
  1589. proxy.msgTip("请稍后", 2);
  1590. res = await proxy.post("/fileService/createTempFolder");
  1591. if (res && res.path) {
  1592. formData.data.contractProductList[index][att] = res.path;
  1593. path = res.path;
  1594. }
  1595. } else {
  1596. path = formData.data.contractProductList[index][att];
  1597. }
  1598. let a = document.createElement("a");
  1599. a.href = "printer://" + "ftp://121.37.194.75/" + path + "/";
  1600. a.style.display = "none";
  1601. document.body.appendChild(a);
  1602. a.click();
  1603. document.body.removeChild(a);
  1604. };
  1605. const handleClickUploadOne = (index) => {
  1606. formData.data.contractProductList[index].isShowProductFile =
  1607. !formData.data.contractProductList[index].isShowProductFile;
  1608. if (formData.data.contractProductList[index].isShowProductFile) {
  1609. formData.data.contractProductList[index].prodFileList = [];
  1610. formData.data.contractProductList[index].fileData = {};
  1611. }
  1612. };
  1613. const getAllData = (businessId) => {
  1614. proxy.post("/contract/detail", { id: businessId }).then(async (res) => {
  1615. res.countryId = res.buyCountryId;
  1616. res.provinceId = res.buyProvinceId;
  1617. res.cityId = res.buyCityId;
  1618. if (res.grossProfitInfoList && res.grossProfitInfoList.length > 0) {
  1619. $bus.emit("getGrossData", res.grossProfitInfoList);
  1620. }
  1621. for (const key in res) {
  1622. formData.data[key] = res[key];
  1623. }
  1624. formData.data.belongType = formData.data.belongType + "";
  1625. formData.data.isFreight = formData.data.isFreight + "";
  1626. formData.data.isTax = formData.data.isTax + "";
  1627. remarkEditor.value.changeHtml(formData.data.templateContent);
  1628. if (
  1629. formData.data.contractProductList &&
  1630. formData.data.contractProductList.length > 0
  1631. ) {
  1632. formData.data.contractProductList.forEach((x) => {
  1633. x.rowId = uuidv4();
  1634. });
  1635. getFileData();
  1636. let productIds = formData.data.contractProductList.map(
  1637. (x) => x.productId
  1638. );
  1639. // proxy.getFileData({
  1640. // businessIdList: productIds,
  1641. // data: formData.data.contractProductList,
  1642. // att: "productId",
  1643. // businessType: "0",
  1644. // fileAtt: "productFile",
  1645. // filePathAtt: "fileUrl",
  1646. // });
  1647. const productAllFile = await proxy.getFileData({
  1648. businessIdList: productIds,
  1649. getAll: true,
  1650. });
  1651. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1652. const ele = formData.data.contractProductList[i];
  1653. for (const key in productAllFile) {
  1654. if (
  1655. ele.productId == key &&
  1656. productAllFile[ele.productId] &&
  1657. productAllFile[ele.productId].length > 0
  1658. ) {
  1659. ele.productFile = productAllFile[ele.productId].filter(
  1660. (x) => x.businessType == "0"
  1661. );
  1662. if (ele.productFile && ele.productFile.length > 0) {
  1663. ele.fileUrl = ele.productFile[0].fileUrl;
  1664. }
  1665. break;
  1666. }
  1667. }
  1668. }
  1669. let ids = formData.data.contractProductList.map((x) => x.id);
  1670. proxy
  1671. .getFileData({
  1672. businessIdList: ids,
  1673. getAll: true,
  1674. })
  1675. .then((fileObj) => {
  1676. if (fileObj && Object.keys(fileObj).length > 0) {
  1677. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1678. const ele = formData.data.contractProductList[i];
  1679. for (const key in fileObj) {
  1680. if (
  1681. ele.id == key &&
  1682. fileObj[ele.id] &&
  1683. fileObj[ele.id].length > 0
  1684. ) {
  1685. let imageUrlList = fileObj[ele.id].filter(
  1686. (x) => x.businessType == "0"
  1687. );
  1688. if (imageUrlList && imageUrlList.length > 0) {
  1689. ele.imageUrl = imageUrlList[0].fileUrl;
  1690. }
  1691. ele.prodFileList = fileObj[ele.id]
  1692. .filter((x) => x.businessType == "1")
  1693. .map((x) => ({ ...x, name: x.fileName, url: x.fileUrl }));
  1694. if (ele.prodFileList && ele.prodFileList.length > 0) {
  1695. ele.isShowProductFile = false;
  1696. } else {
  1697. ele.isShowProductFile = true;
  1698. if (productAllFile[ele.productId]) {
  1699. ele.fileListOne = productAllFile[ele.productId].filter(
  1700. (x) => x.businessType == "2"
  1701. );
  1702. }
  1703. }
  1704. }
  1705. }
  1706. }
  1707. } else {
  1708. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1709. const ele = formData.data.contractProductList[i];
  1710. ele.isShowProductFile = true;
  1711. for (const key in productAllFile) {
  1712. if (
  1713. ele.productId == key &&
  1714. productAllFile[ele.productId] &&
  1715. productAllFile[ele.productId].length > 0
  1716. ) {
  1717. ele.fileListOne = productAllFile[ele.productId].filter(
  1718. (x) => x.businessType == "2"
  1719. );
  1720. break;
  1721. }
  1722. }
  1723. }
  1724. }
  1725. });
  1726. changeProductPrice();
  1727. }
  1728. if (formData.data.countryId) {
  1729. getCityData(formData.data.countryId, "20");
  1730. }
  1731. if (formData.data.provinceId) {
  1732. getCityData(formData.data.provinceId, "30");
  1733. }
  1734. });
  1735. };
  1736. const getFileData = () => {
  1737. let ids = [];
  1738. formData.data.contractProductList.map((x) => {
  1739. // ids.push(x.productId);
  1740. x.contractProductBomList.map((y) => {
  1741. ids.push(y.materialId);
  1742. });
  1743. });
  1744. ids = Array.from(new Set(ids));
  1745. proxy
  1746. .post("/fileInfo/getList", {
  1747. businessIdList: ids,
  1748. })
  1749. .then((fileObj) => {
  1750. formData.data.contractProductList.map((x) => {
  1751. // if (fileObj[x.productId] && fileObj[x.productId].length > 0) {
  1752. // x.fileUrl = fileObj[x.productId][0].fileUrl;
  1753. // }
  1754. x.contractProductBomList.map((y) => {
  1755. y.fileList = fileObj[y.materialId] || [];
  1756. if (y.fileList && y.fileList.length > 0) {
  1757. y.fileUrl = y.fileList[0].fileUrl;
  1758. }
  1759. });
  1760. });
  1761. });
  1762. };
  1763. const getPriceSheetData = (id) => {
  1764. proxy.post("/extQuotation/detail", { id }).then(async (res) => {
  1765. formData.data = res;
  1766. formData.data = {
  1767. contractType: route.query.contractType,
  1768. templateContent: "",
  1769. quotationId: res.id,
  1770. companyId: res.companyId,
  1771. ofCompanyId: res.ofCompanyId,
  1772. buyCorporationId: res.buyCorporationId,
  1773. buyAddress: res.buyAddress,
  1774. buyPostalCode: res.buyPostalCode,
  1775. buyContactName: res.buyContactName,
  1776. buyContactNumber: res.buyContactNumber,
  1777. amount: res.amount,
  1778. };
  1779. // if (res.type == 1) {
  1780. // formData.data.contractType = "2";
  1781. // if (currencyData.value && currencyData.value.length > 0) {
  1782. // formData.data.currency = currencyData.value[0].dictKey;
  1783. // }
  1784. // formData.data.rate = 1;
  1785. // } else {
  1786. // formData.data.contractType = "1";
  1787. // }
  1788. formData.data.contractProductList = res.quotationProductList.map((x) => ({
  1789. quotationProductId: x.id,
  1790. fileUrl: "",
  1791. productId: x.productId,
  1792. productCnName: x.productName,
  1793. productCode: x.productCode,
  1794. productLength: x.productLength,
  1795. productWidth: x.productWidth,
  1796. productHeight: x.productHeight,
  1797. prodFilePath: x.productProdImgPath,
  1798. quantity: x.quantity,
  1799. price: x.price,
  1800. amount: x.amount,
  1801. fileList: [],
  1802. contractProductBomList: x.quotationProductBomList.map((y) => {
  1803. y.quotationProductBomId = y.id;
  1804. delete y.id;
  1805. return y;
  1806. }),
  1807. rowId: uuidv4(),
  1808. }));
  1809. changeProductPrice();
  1810. getFileData();
  1811. let productIds = formData.data.contractProductList.map((x) => x.productId);
  1812. const productAllFile = await proxy.getFileData({
  1813. businessIdList: productIds,
  1814. getAll: true,
  1815. });
  1816. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  1817. const ele = formData.data.contractProductList[i];
  1818. for (const key in productAllFile) {
  1819. if (
  1820. ele.productId == key &&
  1821. productAllFile[ele.productId] &&
  1822. productAllFile[ele.productId].length > 0
  1823. ) {
  1824. ele.productFile = productAllFile[ele.productId].filter(
  1825. (x) => x.businessType == "0"
  1826. );
  1827. if (ele.productFile && ele.productFile.length > 0) {
  1828. ele.fileUrl = ele.productFile[0].fileUrl;
  1829. }
  1830. ele.fileListOne = productAllFile[ele.productId].filter(
  1831. (x) => x.businessType == "2"
  1832. );
  1833. if (ele.fileListOne && ele.fileListOne.length > 0) {
  1834. ele.isShowProductFile = true;
  1835. } else {
  1836. ele.isShowProductFile = false;
  1837. }
  1838. break;
  1839. }
  1840. }
  1841. }
  1842. formData.data.countryId = res.buyCountryId;
  1843. formData.data.provinceId = res.buyProvinceId;
  1844. formData.data.cityId = res.buyCityId;
  1845. if (formData.data.countryId) {
  1846. getCityData(formData.data.countryId, "20");
  1847. }
  1848. if (formData.data.provinceId) {
  1849. getCityData(formData.data.provinceId, "30");
  1850. }
  1851. });
  1852. };
  1853. // 是否能编辑修改产品列表
  1854. const isEditList = ref(true);
  1855. onMounted(() => {
  1856. formData.data.ofCompanyId = proxy.useUserStore().user.companyId;
  1857. handleOfCompanyIdChange(formData.data.ofCompanyId);
  1858. if (
  1859. proxy.useUserStore().currentCompany == proxy.useUserStore().user.ofCompanyId
  1860. ) {
  1861. formData.data.deptId = proxy.useUserStore().user.deptId;
  1862. }
  1863. if (currencyData.value && currencyData.value.length > 0) {
  1864. formData.data.currency = currencyData.value[0].dictKey;
  1865. }
  1866. formOption.disabled = judgeStatus();
  1867. // 报价转销售订单
  1868. if (route.query && route.query.priceSheetId) {
  1869. getPriceSheetData(route.query.priceSheetId);
  1870. isEditList.value = false;
  1871. } else if (route.query && route.query.businessId && route.query.processType) {
  1872. let businessId = route.query.businessId;
  1873. getAllData(businessId);
  1874. } else if (
  1875. route.query &&
  1876. route.query.businessId &&
  1877. !route.query.processType
  1878. ) {
  1879. let businessId = route.query.businessId;
  1880. getAllData(businessId);
  1881. }
  1882. });
  1883. watch(
  1884. () => props.queryData,
  1885. (val) => {
  1886. nextTick(() => {
  1887. formOption.disabled = judgeStatus();
  1888. });
  1889. if (val.businessId && val.processType) {
  1890. getAllData(val.businessId);
  1891. }
  1892. },
  1893. {
  1894. deep: true,
  1895. immediate: true,
  1896. }
  1897. );
  1898. const showPriceInfo = () => {
  1899. if (props.queryData.processType) {
  1900. return false;
  1901. }
  1902. if (route.query.processType) {
  1903. return false;
  1904. } else {
  1905. return true;
  1906. }
  1907. };
  1908. const optionTwo = reactive({
  1909. data: {
  1910. tooltip: {
  1911. trigger: "axis",
  1912. },
  1913. // legend: {
  1914. // data: ["价格"],
  1915. // },
  1916. grid: {
  1917. left: "3%",
  1918. right: "4%",
  1919. top: "10%",
  1920. bottom: "3%",
  1921. containLabel: true,
  1922. },
  1923. // toolbox: {
  1924. // feature: {
  1925. // saveAsImage: {},
  1926. // },
  1927. // },
  1928. xAxis: {
  1929. type: "category",
  1930. boundaryGap: false,
  1931. data: [],
  1932. },
  1933. yAxis: {
  1934. type: "value",
  1935. },
  1936. series: [
  1937. {
  1938. name: "价格",
  1939. type: "line",
  1940. data: [],
  1941. },
  1942. ],
  1943. },
  1944. });
  1945. const showEcharts = (row, index) => {
  1946. let myChart = null;
  1947. myChart = echarts.init(proxy.$refs[row.productId + index]);
  1948. window.addEventListener("resize", () => {
  1949. myChart.resize();
  1950. });
  1951. if (row.contractProductListOne && row.contractProductListOne.length > 0) {
  1952. optionTwo.data.xAxis.data = row.contractProductListOne.map((item) => {
  1953. return item.createTime.slice(0, 10);
  1954. });
  1955. optionTwo.data.series[0].data = row.contractProductListOne.map((item) => {
  1956. return item.price;
  1957. });
  1958. } else {
  1959. optionTwo.data.xAxis.data = [];
  1960. optionTwo.data.series[0].data = [];
  1961. }
  1962. myChart.setOption(optionTwo.data);
  1963. myChart.resize();
  1964. };
  1965. const clickCopy = (type) => {
  1966. copyType.value = type;
  1967. copyContract.value = true;
  1968. };
  1969. </script>
  1970. <style lang="scss" scoped>
  1971. .img {
  1972. object-fit: contain;
  1973. width: 16px;
  1974. height: 16px;
  1975. vertical-align: middle;
  1976. }
  1977. .pic {
  1978. object-fit: contain;
  1979. width: 50px;
  1980. height: 50px;
  1981. cursor: pointer;
  1982. vertical-align: middle;
  1983. }
  1984. .el-icon.avatar-uploader-icon {
  1985. font-size: 20px;
  1986. color: #8c939d;
  1987. width: 50px;
  1988. height: 50px;
  1989. text-align: center;
  1990. border: 1px dashed var(--el-border-color);
  1991. }
  1992. .ql-editor {
  1993. padding: 0px;
  1994. }
  1995. :deep(.el-upload-list) {
  1996. margin: 0px !important;
  1997. position: relative;
  1998. top: -8px;
  1999. left: -8px;
  2000. }
  2001. :deep(.el-upload-list--text .el-upload-list__item) {
  2002. min-width: 150px !important;
  2003. }
  2004. :deep(.bom-table .el-table__body-wrapper .el-table__body .el-table__row) {
  2005. background: #f4f4f5 !important;
  2006. }
  2007. </style>