index.vue 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916
  1. <template>
  2. <div class="box">
  3. <div class="tree">
  4. <treeList title="产品分类" submitType="1" :data="treeListData" v-model="sourceList.pagination.productClassifyId" @change="treeChange"
  5. @changeTreeList="getTreeList">
  6. </treeList>
  7. </div>
  8. <div class="content">
  9. <byTable :source="sourceList.data" :tableHeight="tableHeight" :pagination="sourceList.pagination" :config="config" :loading="loading"
  10. highlight-current-row :selectConfig="selectConfig" :action-list="[
  11. {
  12. text: '导出产品BOM Excel',
  13. action: () => exportBomExcel(),
  14. disabled: false,
  15. },
  16. {
  17. text: '导出Excel',
  18. action: () => exportExcel(),
  19. disabled: false,
  20. },
  21. {
  22. text: '添加',
  23. action: () => openModal('add'),
  24. disabled: false,
  25. },]" @get-list="getList">
  26. <template #name="{ item }">
  27. <div>
  28. <span class="el-click">{{ item.name }}</span>
  29. </div>
  30. </template>
  31. <template #pic="{ item }">
  32. <div v-if="item.fileList.length > 0">
  33. <img :src="item.fileList[0].fileUrl" class="pic" @click="handleClickFile(item.fileList[0])" />
  34. </div>
  35. <div v-else></div>
  36. </template>
  37. <template #size="{ item }">
  38. <div v-if="item['length'] && item.width && item.height">
  39. <span>{{ item['length'] }}</span>*
  40. <span>{{ item.width }}</span>*
  41. <span>{{ item.height }}</span>
  42. </div>
  43. <div v-else></div>
  44. </template>
  45. <template #price="{ item }">
  46. <div v-if="item.price">
  47. <span> {{ moneyFormat(item.price ,2)}}</span>
  48. </div>
  49. <div v-else></div>
  50. </template>
  51. </byTable>
  52. </div>
  53. <el-dialog :title="modalType == 'add' ? '添加产品' : '编辑产品'" v-model="dialogVisible" width="90%" destroy-on-close>
  54. <div class="public_height_dialog">
  55. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom" v-loading="submitLoading">
  56. <template #nameEnglish>
  57. <div style="width: 100%">
  58. <el-input v-model="formData.data.nameEnglish" placeholder="请输入" onkeyup="value=value.replace(/[^\x00-\xff]/g, '')"></el-input>
  59. </div>
  60. </template>
  61. <template #productionFile>
  62. <div style="width: 100%">
  63. <span style="color:#409eff;cursor:pointer" @click="handleClickUpload('prodFilePath',true)"
  64. v-if="!formData.data.prodFilePath">点击上传</span>
  65. <span style="color:#409eff;cursor:pointer" @click="handleClickUpload('prodFilePath',false)" v-else>点击查看</span>
  66. </div>
  67. </template>
  68. <template #productionFileOne>
  69. <div style="width: 100%">
  70. <el-button type="primary" plain @click="handleClickUpload('prodImgPath',true)" v-if="!formData.data.prodImgPath">点击上传</el-button>
  71. <el-button type="primary" plain @click="handleClickUpload('prodImgPath',false)" v-else>点击查看</el-button>
  72. </div>
  73. </template>
  74. <template #rawMaterialIdSlot>
  75. <div style="width:100%;padding-left:25px">
  76. <div>
  77. <el-button type="primary" @click="openDialog(1)" plain>主材</el-button>
  78. <el-button type="primary" @click="openDialog(2)" plain>工艺</el-button>
  79. <el-button type="primary" @click="openDialog(3)" plain>辅材</el-button>
  80. </div>
  81. <el-table :data="formData.data.productBomDetailList" style="width: 100%; margin-top: 16px">
  82. <el-table-column prop="materialName" label="物料名称" width="170" />
  83. <el-table-column prop="materialCode" label="物料编码" width="190" />
  84. <el-table-column label="规格尺寸 (cm)" width="140">
  85. <template #default="{ row, $index }">
  86. <div style="width: 100%" v-if="row.materialLength&&row.materialWidth && row.materialHeight">
  87. {{row.materialLength}}*{{row.materialWidth}}*{{row.materialHeight}}
  88. </div>
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="materialColor" label="颜色" width="170" />
  92. <!-- <el-table-column label="数量" width="150">
  93. <template #default="{ row, $index }">
  94. <div style="width: 100%">
  95. <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true"
  96. class="margin-b-0 wid100">
  97. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  98. :controls="false" :min="1" />
  99. </el-form-item>
  100. </div>
  101. </template>
  102. </el-table-column> -->
  103. <el-table-column label="标准用量" width="150">
  104. <template #default="{ row, $index }">
  105. <div style="width: 100%">
  106. <el-form-item :prop="'productBomDetailList.' + $index + '.standardDosage'" :rules="rules.standardDosage" :inline-message="true"
  107. class="margin-b-0 wid100">
  108. <el-input-number onmousewheel="return false;" v-model="row.standardDosage" placeholder="请输入" style="width: 100%"
  109. :precision="0" :controls="false" :min="1" />
  110. </el-form-item>
  111. </div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="损耗率(%)" width="150">
  115. <template #default="{ row, $index }">
  116. <div style="width: 100%">
  117. <el-form-item :prop="'productBomDetailList.' + $index + '.lossRate'" :rules="rules.lossRate" :inline-message="true"
  118. class="margin-b-0 wid100">
  119. <el-input-number onmousewheel="return false;" v-model="row.lossRate" placeholder="请输入" style="width: 100%" :precision="2"
  120. :controls="false" :min="0" :max="100" />
  121. </el-form-item>
  122. </div>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="备注" min-width="200">
  126. <template #default="{ row, $index }">
  127. <div style="width: 100%">
  128. <el-form-item :prop="'productBomDetailList.' + $index + '.remark'" :rules="rules.remark" :inline-message="true"
  129. class="margin-b-0 wid100">
  130. <el-input v-model="row.remark" placeholder="请输入"> </el-input>
  131. </el-form-item>
  132. </div>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="操作" width="60" align="center" fixed="right">
  136. <template #default="{ row, $index }">
  137. <el-button type="primary" link @click="handleRemove($index,1)" v-if="row.type !=3">删除</el-button>
  138. </template>
  139. </el-table-column>
  140. </el-table>
  141. <!-- <el-table :data="formData.data.rawMaterialList" style="width: 100%; margin-top: 16px">
  142. <el-table-column prop="rawMaterialName" label="原材料名称" />
  143. <el-table-column prop="rawMaterialCode" label="原材料编码" />
  144. <el-table-column label="规格尺寸 (cm)">
  145. <template #default="{ row, $index }">
  146. <div style="width: 100%" v-if="row.rawMaterialLength&&row.rawMaterialWidth && row.rawMaterialHeight">
  147. {{row.rawMaterialLength}}*{{row.rawMaterialWidth}}*{{row.rawMaterialHeight}}
  148. </div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column prop="rawMaterialColor" label="颜色" />
  152. </el-table> -->
  153. </div>
  154. </template>
  155. <template #color>
  156. <div style="width: 100%">
  157. <el-form-item label="颜色" class="margin-b-0 wid100">
  158. <el-row style="width: 100%">
  159. <el-col :span="12">
  160. <el-form-item prop="color" label-width="0px" class="margin-b-0 wid100">
  161. <el-input v-model="formData.data.color" placeholder="颜色" />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="12">
  165. <el-form-item prop="colorCardCode" label-width="0px" class="margin-b-0 wid100">
  166. <el-input v-model="formData.data.colorCardCode" placeholder="色卡号" />
  167. </el-form-item>
  168. </el-col>
  169. </el-row>
  170. </el-form-item>
  171. </div>
  172. </template>
  173. <template #size>
  174. <div style="width: 100%">
  175. <el-form-item label="尺寸" class="margin-b-0 wid100" required>
  176. <el-row>
  177. <el-col :span="8">
  178. <el-form-item prop="length" label-width="0px" class="margin-b-0 wid100">
  179. <el-input-number v-model="formData.data['length']" placeholder="长 (cm)" style="width: 100%" :precision="2" :controls="false"
  180. :min="0" onmousewheel="return false;" />
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="8">
  184. <el-form-item prop="width" label-width="0px" class="margin-b-0 wid100">
  185. <el-input-number v-model="formData.data.width" placeholder="宽 (cm)" style="width: 100%" :precision="2" :controls="false"
  186. :min="0" onmousewheel="return false;" />
  187. </el-form-item>
  188. </el-col>
  189. <el-col :span="8">
  190. <el-form-item prop="height" label-width="0px" class="margin-b-0 wid100">
  191. <el-input-number v-model="formData.data.height" placeholder="高 (cm)" style="width: 100%" :precision="2" :controls="false"
  192. :min="0" onmousewheel="return false;" />
  193. </el-form-item>
  194. </el-col>
  195. </el-row>
  196. </el-form-item>
  197. </div>
  198. </template>
  199. <template #materialDetail>
  200. <div style="width: 100%;padding-left:15px">
  201. <el-button type="primary" @click="clickOpenSelectMaterial(1)" plain>选择包材/配件/辅材</el-button>
  202. <el-table :data="formData.data.productBomDetailList" style="width: 100%; margin-top: 16px">
  203. <el-table-column prop="materialName" label="物料名称" />
  204. <el-table-column prop="materialCode" label="物料编码" />
  205. <el-table-column label="规格尺寸 (cm)" width="140">
  206. <template #default="{ row, $index }">
  207. <div style="width: 100%" v-if="row.materialLength&&row.materialWidth && row.materialHeight">
  208. {{row.materialLength}}*{{row.materialWidth}}*{{row.materialHeight}}
  209. </div>
  210. </template>
  211. </el-table-column>
  212. <el-table-column prop="materialColor" label="颜色" width="170" />
  213. <el-table-column label="数量" width="150">
  214. <template #default="{ row, $index }">
  215. <div style="width: 100%">
  216. <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true"
  217. class="margin-b-0 wid100">
  218. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  219. :controls="false" :min="1" />
  220. </el-form-item>
  221. </div>
  222. </template>
  223. </el-table-column>
  224. <el-table-column label="操作" width="60" align="center" fixed="right">
  225. <template #default="{ $index }">
  226. <el-button type="primary" link @click="handleRemove($index,1)">删除</el-button>
  227. </template>
  228. </el-table-column>
  229. </el-table>
  230. </div>
  231. </template>
  232. <template #technology>
  233. <div style="width:100%">
  234. <!-- <div class="small-title">
  235. ① 工艺线路
  236. </div>
  237. <el-row style="width:100%">
  238. <el-col :span="12">
  239. <el-form-item prop="technologyId" label="生产工艺" class="wid100">
  240. <el-select v-model="formData.data.technologyId" placeholder="请选择" style="width:100%">
  241. <el-option v-for="item in technologyData" :key="item.id" :label="item.name" :value="item.id" />
  242. </el-select>
  243. </el-form-item>
  244. </el-col>
  245. </el-row> -->
  246. <div class="small-title">
  247. ① LOGO
  248. </div>
  249. <el-row style="width:100%">
  250. <el-col :span="12">
  251. <el-form-item label="LOGO尺寸" class="wid100">
  252. <el-row style="width:100%">
  253. <el-col :span="12">
  254. <el-form-item prop="logoLength" label-width="0px" class="margin-b-0 wid100">
  255. <el-input-number v-model="formData.data.logoLength" placeholder="长 (cm)" style="width: 100%" :precision="2"
  256. :controls="false" :min="0" onmousewheel="return false;" />
  257. </el-form-item>
  258. </el-col>
  259. <el-col :span="12">
  260. <el-form-item prop="logoWidth" label-width="0px" class="margin-b-0 wid100">
  261. <el-input-number v-model="formData.data.logoWidth" placeholder="宽 (cm)" style="width: 100%" :precision="2" :controls="false"
  262. :min="0" onmousewheel="return false;" />
  263. </el-form-item>
  264. </el-col>
  265. <!-- <el-col :span="8">
  266. <el-form-item prop="logoHeight" label-width="0px" class="margin-b-0 wid100">
  267. <el-input-number v-model="formData.data.logoHeight" placeholder="高 (cm)" style="width: 100%" :precision="2"
  268. :controls="false" :min="0" onmousewheel="return false;" />
  269. </el-form-item>
  270. </el-col> -->
  271. </el-row>
  272. </el-form-item>
  273. </el-col>
  274. <el-col :span="12">
  275. <el-form-item prop="colorCount" label="几色印刷" class="wid100">
  276. <el-input-number v-model="formData.data.colorCount" placeholder="请输入" style="width: 100%" :precision="0" :controls="false"
  277. :min="1" onmousewheel="return false;" />
  278. </el-form-item>
  279. </el-col>
  280. </el-row>
  281. <div class="small-title">
  282. ② 折叠
  283. </div>
  284. <el-row style="width:100%">
  285. <el-col :span="12">
  286. <el-form-item prop="isFold" label="是否折叠" class="wid100">
  287. <el-select v-model="formData.data.isFold" placeholder="请选择" style="width:100%">
  288. <el-option :label="'否'" :value="0" />
  289. <el-option :label="'是'" :value="1" />
  290. </el-select>
  291. </el-form-item>
  292. </el-col>
  293. <el-col :span="12">
  294. <el-form-item prop="foldWay" label="折叠数" class="wid100" v-if="formData.data.isFold==1"
  295. :rules="formData.data.isFold==1?rules.foldWay:''">
  296. <el-select v-model="formData.data.foldWay" placeholder="请选择" style="width:100%">
  297. <el-option v-for="item in foldWayData" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  298. </el-select>
  299. </el-form-item>
  300. </el-col>
  301. </el-row>
  302. <div class="small-title">
  303. ③ 包装要求
  304. </div>
  305. <el-row style="width:100%">
  306. <el-col :span="12">
  307. <el-form-item prop="packAsk" label="包装要求" class="wid100">
  308. <el-select v-model="formData.data.packAsk" placeholder="请选择" style="width:100%" multiple>
  309. <el-option v-for="item in packAskData" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  310. </el-select>
  311. </el-form-item>
  312. </el-col>
  313. </el-row>
  314. <div class="small-title">
  315. ④ 是否定制
  316. </div>
  317. <el-row style="width:100%">
  318. <el-col :span="12">
  319. <el-form-item prop="isCustomized" label="是否定制" class="wid100">
  320. <el-select v-model="formData.data.isCustomized" placeholder="请选择" style="width:100%" @change="handleChangeIsCustomized">
  321. <el-option :label="'否'" :value="0" />
  322. <el-option :label="'是'" :value="1" />
  323. </el-select>
  324. </el-form-item>
  325. </el-col>
  326. </el-row>
  327. <el-row style="width:100%">
  328. <el-form-item prop="technologyId" label="定制内容" class="wid100" v-if="formData.data.isCustomized==1">
  329. <table style="width:100%" border class="table">
  330. <tr>
  331. <td style="width:20%">
  332. </td>
  333. <td style="width:40%">附件</td>
  334. <td style="width:40%">备注</td>
  335. </tr>
  336. <tr v-for="(row,index) in formData.data.productCustomInfoList" :key="index">
  337. <td>
  338. <el-checkbox v-model="row.isCheckBox" label="" /> <span style="position:relative;top:-2px"> {{getLabel(row.type)}}</span>
  339. </td>
  340. <td>
  341. <el-upload :file-list="row.fileList" :action="uploadUrl" :data="uploadData" :limit="5" :list-type="'text'"
  342. :before-upload="(file)=>handleBeforeUploadOne(file,index)" :on-success="()=>handleSuccessOne(index)"
  343. :on-remove="(file)=>handleRemoveFile(file,index)" :on-preview="onPreviewFile"
  344. :on-exceed="()=>msgTip(`上传文件数量不可大于5`, 2)">
  345. <el-button text type="primary">上传附件</el-button>
  346. </el-upload>
  347. </td>
  348. <td>
  349. <el-form-item :prop="'productCustomInfoList.' + index + '.remark'" :rules="row.isCheckBox?rules.remark:''"
  350. class="margin-b-0 wid100">
  351. <el-input v-model="row.remark" placeholder="请输入备注" />
  352. </el-form-item>
  353. </td>
  354. </tr>
  355. </table>
  356. </el-form-item>
  357. </el-row>
  358. </div>
  359. </template>
  360. </byForm>
  361. </div>
  362. <template #footer>
  363. <el-button @click="dialogVisible = false" size="defualt" v-debounce>取 消</el-button>
  364. <el-button type="primary" @click="submitForm()" size="defualt" v-debounce>确 定</el-button>
  365. </template>
  366. </el-dialog>
  367. <el-dialog :title="'BOM 配置'" v-model="bomDialog" width="900" destroy-on-close>
  368. <!-- <div class="public_height_dialog"> -->
  369. <byForm :formConfig="bomFormConfig" :formOption="bomFormOption" v-model="formData.bomData" :rules="bomRules" ref="bomFormDom"
  370. v-loading="submitLoading">
  371. <!-- <template #accessories>
  372. <div style="width: 100%">
  373. <el-button type="primary" @click="openSelectMaterial = true" plain>选择</el-button>
  374. <el-table :data="formData.bomData.productBomDetailList" style="width: 100%; margin-top: 16px" border>
  375. <el-table-column prop="materialName" label="物料名称" min-width="130" />
  376. <el-table-column prop="materialCode" label="物料编码" width="150" />
  377. <el-table-column label="数量" width="150">
  378. <template #default="{ row, $index }">
  379. <div style="width: 100%">
  380. <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="bomRules.quantity" :inline-message="true"
  381. class="margin-b-0 wid100">
  382. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  383. :controls="false" :min="1" />
  384. </el-form-item>
  385. </div>
  386. </template>
  387. </el-table-column>
  388. <el-table-column label="操作" width="60" align="center" fixed="right">
  389. <template #default="{ $index }">
  390. <el-button type="primary" link @click="handleRemove($index,1)">删除</el-button>
  391. </template>
  392. </el-table-column>
  393. </el-table>
  394. </div>
  395. </template>
  396. <template #detail>
  397. <div style="width: 100%">
  398. <el-table :data="formData.bomData.processesList" style="width: 100%; " border>
  399. <el-table-column label="序号" type="index" width="80" />
  400. <el-table-column prop="code" label="工序编码" />
  401. <el-table-column prop="name" label="工序名称" />
  402. </el-table>
  403. </div>
  404. </template> -->
  405. <template #detail>
  406. <div style="width: 100%">
  407. <div style="text-align:center;margin-bottom:10px">
  408. 【{{formData.bomData.name}} {{formData.bomData.code}}】BOM单
  409. </div>
  410. <table border class="table" style="width:100%">
  411. <tbody>
  412. <tr>
  413. <td style="width:90px">原材料</td>
  414. <td style="padding:10px">
  415. <el-select v-model="formData.bomData.rawMaterialId" filterable placeholder="请选择原材料" style="width:100%">
  416. <el-option v-for="item in rawMaterialData" :key="item.value" :label="item.label" :value="item.value" />
  417. </el-select>
  418. </td>
  419. </tr>
  420. <tr>
  421. <td>
  422. 包材/配件/辅材
  423. </td>
  424. <td style="padding:20px 20px 20px">
  425. <div style="text-align:left"><el-button type="primary" @click="clickOpenSelectMaterial(2)" plain>选择</el-button></div>
  426. <el-table :data="formData.bomData.productBomDetailList" style="width: 100%;">
  427. <el-table-column prop="materialName" label="物料名称" min-width="130" />
  428. <el-table-column prop="materialCode" label="物料编码" width="150" />
  429. <el-table-column label="规格尺寸 (cm)" width="140">
  430. <template #default="{ row, $index }">
  431. <div style="width: 100%" v-if="row.materialLength&&row.materialWidth && row.materialHeight">
  432. {{row.materialLength}}*{{row.materialWidth}}*{{row.materialHeight}}
  433. </div>
  434. </template>
  435. </el-table-column>
  436. <el-table-column prop="materialColor" label="颜色" width="150" />
  437. <el-table-column label="数量" width="100">
  438. <template #default="{ row, $index }">
  439. <div style="width: 100%">
  440. <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="bomRules.quantity" :inline-message="true"
  441. class="margin-b-0 wid100">
  442. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%"
  443. :precision="0" :controls="false" :min="1" />
  444. </el-form-item>
  445. </div>
  446. </template>
  447. </el-table-column>
  448. <el-table-column label="操作" width="60" align="center" fixed="right">
  449. <template #default="{ $index }">
  450. <el-button type="primary" link @click="handleRemove($index,2)">删除</el-button>
  451. </template>
  452. </el-table-column>
  453. </el-table>
  454. </td>
  455. </tr>
  456. <tr>
  457. <td>
  458. 生产工序
  459. </td>
  460. <td style="padding:0 20px 20px">
  461. <el-table :data="formData.bomData.processesList" style="width: 100%; ">
  462. <el-table-column label="序号" type="index" width="80" />
  463. <el-table-column prop="code" label="工序编码" />
  464. <el-table-column prop="name" label="工序名称" />
  465. </el-table>
  466. </td>
  467. </tr>
  468. </tbody>
  469. </table>
  470. </div>
  471. </template>
  472. </byForm>
  473. <!-- </div> -->
  474. <template #footer>
  475. <el-button @click="bomDialog = false" size="defualt" v-debounce>取 消</el-button>
  476. <el-button type="primary" @click="submitBomForm()" size="defualt" v-debounce>确 定</el-button>
  477. </template>
  478. </el-dialog>
  479. <el-dialog :title="'物料选择'" v-model="openSelectMaterial" width="90%" destroy-on-close>
  480. <SelectMaterial :isNeRawMaterial="'1'" @selectMaterial="selectMaterial"></SelectMaterial>
  481. <template #footer>
  482. <el-button @click="openSelectMaterial = false" size="defualt" v-debounce>取 消</el-button>
  483. </template>
  484. </el-dialog>
  485. <el-dialog :title="'原材料选择'" v-model="openSelectRawMaterial" width="90%" destroy-on-close>
  486. <SelectMaterial :ancestors="100" @selectMaterial="selectRawMaterial"></SelectMaterial>
  487. <template #footer>
  488. <el-button @click="openSelectRawMaterial = false" size="defualt" v-debounce>取 消</el-button>
  489. </template>
  490. </el-dialog>
  491. <el-dialog :title="'工艺选择'" v-model="openSelectTechnology" width="90%" destroy-on-close>
  492. <SelectTechnology :isSelect="true" @selectTechnology="selectTechnology"></SelectTechnology>
  493. <template #footer>
  494. <el-button @click="openSelectTechnology = false" size="defualt" v-debounce>取 消</el-button>
  495. </template>
  496. </el-dialog>
  497. <el-dialog title="导入产品" v-model="openExcelDialog" width="400">
  498. <div v-loading="excelLoading">
  499. <el-upload :action="actionUrl + '/productInfo/excelImportByEhsd'" :headers="headers" :on-success="handleSuccess" :on-progress="handleProgress"
  500. :show-file-list="false" :on-error="handleError" accept=".xlsx">
  501. <el-button type="primary">点击导入</el-button>
  502. </el-upload>
  503. </div>
  504. <template #footer>
  505. <el-button @click="openExcelDialog = false" size="default" v-debounce>取 消</el-button>
  506. </template>
  507. </el-dialog>
  508. </div>
  509. </template>
  510. <script setup>
  511. import byTable from "@/components/byTable/index";
  512. import byForm from "@/components/byForm/index";
  513. import treeList from "@/components/product/treeList";
  514. import SelectMaterial from "@/components/product/SelectMaterial.vue";
  515. import { getToken } from "@/utils/auth";
  516. import SelectTechnology from "@/views/production/project/technology/index.vue";
  517. const { proxy } = getCurrentInstance();
  518. const actionUrl = import.meta.env.VITE_APP_BASE_API;
  519. const loading = ref(false);
  520. const submitLoading = ref(false);
  521. const treeData = ref([]);
  522. const treeDataOne = ref([]);
  523. const treeListData = ref([]);
  524. const technologyData = ref([]);
  525. const companyData = ref([]);
  526. const currencyData = computed(
  527. () => proxy.useUserStore().allDict["account_currency"]
  528. );
  529. const packAskData = computed(() => proxy.useUserStore().allDict["pack_ask"]);
  530. const foldWayData = computed(() => proxy.useUserStore().allDict["fold_way"]);
  531. const backLinesData = computed(
  532. () => proxy.useUserStore().allDict["back_lines"]
  533. );
  534. const frontLinesData = computed(
  535. () => proxy.useUserStore().allDict["front_lines"]
  536. );
  537. const headers = ref({ Authorization: "Bearer " + getToken() });
  538. const uploadData = ref({});
  539. const tableHeight = ref(0);
  540. const getTableHeight = () => {
  541. tableHeight.value = window.innerHeight - 245;
  542. };
  543. getTableHeight();
  544. window.addEventListener("resize", () => {
  545. getTableHeight();
  546. });
  547. const sourceList = ref({
  548. data: [],
  549. pagination: {
  550. total: 3,
  551. pageNum: 1,
  552. pageSize: 10,
  553. type: "",
  554. productClassifyId: "",
  555. keyword: "",
  556. definition: "1",
  557. companyId: "",
  558. },
  559. });
  560. const dialogVisible = ref(false);
  561. const openExcelDialog = ref(false);
  562. const excelLoading = ref(false);
  563. const modalType = ref("add");
  564. const rules = ref({
  565. companyId: [{ required: true, message: "请选择归属公司", trigger: "change" }],
  566. productClassifyId: [
  567. { required: true, message: "请选择产品分类", trigger: "change" },
  568. ],
  569. name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
  570. customCode: [{ required: true, message: "请输入产品编号", trigger: "blur" }],
  571. length: [{ required: true, message: "请输入长 (cm)", trigger: "blur" }],
  572. width: [{ required: true, message: "请输入宽 (cm)", trigger: "blur" }],
  573. height: [{ required: true, message: "请输入高 (cm)", trigger: "blur" }],
  574. technologyId: [
  575. { required: true, message: "请选择生产工艺", trigger: "change" },
  576. ],
  577. rawMaterialId: [
  578. { required: true, message: "请选择原材料", trigger: "change" },
  579. ],
  580. foldWay: [{ required: true, message: "请选择折叠数", trigger: "change" }],
  581. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  582. standardDosage: [
  583. { required: true, message: "请输入标准用量", trigger: "blur" },
  584. ],
  585. lossRate: [{ required: true, message: "请输入损耗率", trigger: "blur" }],
  586. // remark: [{ required: true, message: "请输入描述", trigger: "blur" }],
  587. // reverseTexture: [
  588. // { required: true, message: "请选择背面纹路", trigger: "change" },
  589. // ],
  590. // frontalTexture: [
  591. // { required: true, message: "请选择正面纹路", trigger: "change" },
  592. // ],
  593. });
  594. const props = defineProps({
  595. selectStatus: Boolean,
  596. });
  597. const selectConfig = computed(() => [
  598. {
  599. label: "业务公司",
  600. prop: "companyId",
  601. data: companyData.value,
  602. },
  603. ]);
  604. const config = computed(() => {
  605. return [
  606. {
  607. attrs: {
  608. label: "图片",
  609. slot: "pic",
  610. align: "center",
  611. width: 80,
  612. },
  613. },
  614. {
  615. attrs: {
  616. label: "业务公司",
  617. prop: "companyName",
  618. width: 150,
  619. },
  620. },
  621. {
  622. attrs: {
  623. label: "产品分类",
  624. prop: "classifyName",
  625. "min-width": 200,
  626. },
  627. },
  628. {
  629. attrs: {
  630. label: "产品编码",
  631. prop: "customCode",
  632. width: 180,
  633. },
  634. },
  635. {
  636. attrs: {
  637. label: "产品名称",
  638. slot: "name",
  639. "min-width": 200,
  640. },
  641. },
  642. // {
  643. // attrs: {
  644. // label: "产品英文名",
  645. // prop: "nameEnglish",
  646. // "min-width": 120,
  647. // },
  648. // },
  649. // {
  650. // attrs: {
  651. // label: "规格尺寸 (cm)",
  652. // prop: "spec",
  653. // width: 120,
  654. // },
  655. // },
  656. {
  657. attrs: {
  658. label: "规格尺寸 (cm)",
  659. slot: "size",
  660. width: 130,
  661. },
  662. },
  663. {
  664. attrs: {
  665. label: "颜色",
  666. prop: "color",
  667. width: 100,
  668. },
  669. },
  670. {
  671. attrs: {
  672. label: "计量单位",
  673. prop: "unit",
  674. width: 100,
  675. },
  676. },
  677. {
  678. attrs: {
  679. label: "正面纹路",
  680. prop: "frontalTexture",
  681. width: 130,
  682. },
  683. render(val) {
  684. return proxy.dictKeyValue(val, frontLinesData.value);
  685. },
  686. },
  687. {
  688. attrs: {
  689. label: "净重",
  690. prop: "netWeight",
  691. width: 100,
  692. },
  693. render(val) {
  694. if (val) {
  695. return val + " kg";
  696. }
  697. },
  698. },
  699. {
  700. attrs: {
  701. label: "销售价",
  702. prop: "price",
  703. width: 100,
  704. },
  705. render(val) {
  706. return proxy.moneyFormat(val, 2);
  707. },
  708. },
  709. // {
  710. // attrs: {
  711. // label: "海关编码",
  712. // prop: "hsCode",
  713. // width: 100,
  714. // },
  715. // },
  716. {
  717. attrs: {
  718. label: "原材料编码",
  719. prop: "rawMaterialCode",
  720. width: 120,
  721. },
  722. },
  723. {
  724. attrs: {
  725. label: "原材料",
  726. prop: "rawMaterialName",
  727. "min-width": 300,
  728. },
  729. },
  730. {
  731. attrs: {
  732. label: "操作",
  733. width: "160",
  734. align: "center",
  735. fixed: "right",
  736. },
  737. renderHTML(row) {
  738. return [
  739. // {
  740. // attrs: {
  741. // label: "选择",
  742. // type: "primary",
  743. // text: true,
  744. // },
  745. // el: "button",
  746. // click() {
  747. // clickSelect(row);
  748. // },
  749. // }
  750. // {
  751. // attrs: {
  752. // label: "BOM",
  753. // type: "primary",
  754. // text: true,
  755. // },
  756. // el: "button",
  757. // click() {
  758. // bomSetting(row);
  759. // },
  760. // },
  761. {
  762. attrs: {
  763. label: "修改",
  764. type: "primary",
  765. text: true,
  766. },
  767. el: "button",
  768. click() {
  769. getDtl(row);
  770. },
  771. },
  772. {
  773. attrs: {
  774. label: "删除",
  775. type: "danger",
  776. text: true,
  777. },
  778. el: "button",
  779. click() {
  780. proxy
  781. .msgConfirm()
  782. .then((res) => {
  783. proxy
  784. .post("/productInfo/delete", {
  785. id: row.id,
  786. })
  787. .then((res) => {
  788. proxy.msgTip("删除成功", 1);
  789. getList();
  790. });
  791. })
  792. .catch((err) => {});
  793. },
  794. },
  795. ];
  796. },
  797. },
  798. ];
  799. });
  800. const getPriceData = () => {
  801. if (
  802. formData.data["length"] &&
  803. formData.data.width &&
  804. formData.data.technologyId &&
  805. formData.data.rawMaterialId
  806. ) {
  807. proxy
  808. .post("/productInfo/getProductPrice", {
  809. id: formData.data.id || "",
  810. length: formData.data["length"],
  811. width: formData.data.width,
  812. technologyId: formData.data.technologyId,
  813. rawMaterialId: formData.data.rawMaterialId,
  814. })
  815. .then((res) => {
  816. formData.data.price = res.price;
  817. });
  818. }
  819. };
  820. const formData = reactive({
  821. data: {},
  822. bomData: {},
  823. });
  824. const formOption = reactive({
  825. disabled: false,
  826. inline: true,
  827. labelWidth: 100,
  828. itemWidth: 100,
  829. });
  830. const formDom = ref(null);
  831. const formConfig = computed(() => {
  832. return [
  833. {
  834. type: "title1",
  835. title: "基本信息",
  836. },
  837. {
  838. type: "treeSelect",
  839. prop: "companyId",
  840. label: "业务公司",
  841. data: treeDataOne.value,
  842. propsTreeLabel: "deptName",
  843. propsTreeValue: "deptId",
  844. itemWidth: 50,
  845. },
  846. {
  847. type: "treeSelect",
  848. prop: "productClassifyId",
  849. label: "产品分类",
  850. data: treeData.value,
  851. itemWidth: 50,
  852. disabled: false,
  853. },
  854. {
  855. type: "input",
  856. prop: "name",
  857. label: "产品名称",
  858. itemWidth: 50,
  859. disabled: false,
  860. },
  861. {
  862. type: "slot",
  863. slotName: "nameEnglish",
  864. label: "英文名",
  865. itemWidth: 50,
  866. },
  867. {
  868. type: "input",
  869. prop: "customCode",
  870. label: "产品编号",
  871. itemWidth: 50,
  872. disabled: false,
  873. },
  874. {
  875. type: "select",
  876. prop: "frontalTexture",
  877. label: "正面纹路",
  878. data: frontLinesData.value,
  879. itemWidth: 50,
  880. },
  881. {
  882. type: "select",
  883. prop: "reverseTexture",
  884. label: "背面纹路",
  885. data: backLinesData.value,
  886. itemWidth: 50,
  887. },
  888. {
  889. type: "input",
  890. prop: "unit",
  891. label: "计量单位",
  892. itemWidth: 50,
  893. disabled: false,
  894. },
  895. {
  896. type: "input",
  897. prop: "hsCode",
  898. label: "海关编码",
  899. itemWidth: 50,
  900. disabled: false,
  901. },
  902. {
  903. type: "slot",
  904. slotName: "color",
  905. prop: "",
  906. label: "",
  907. itemWidth: 50,
  908. disabled: false,
  909. },
  910. {
  911. type: "slot",
  912. slotName: "size",
  913. prop: "",
  914. label: "",
  915. itemWidth: 50,
  916. disabled: false,
  917. },
  918. {
  919. type: "number",
  920. prop: "netWeight",
  921. label: "净重(kg)",
  922. precision: 2,
  923. min: 0,
  924. controls: false,
  925. itemWidth: 50,
  926. },
  927. {
  928. type: "input",
  929. itemType: "textarea",
  930. prop: "remark",
  931. label: "描述",
  932. itemWidth: 100,
  933. disabled: false,
  934. },
  935. {
  936. type: "uploadImg",
  937. // listType: "picture-card",
  938. // limit: 1,
  939. // accept: ".gif, .jpeg, .jpg, .png",
  940. prop: "fileList",
  941. imgProp: "imageUrl",
  942. label: "产品缩略图",
  943. itemWidth: 100,
  944. },
  945. {
  946. type: "slot",
  947. slotName: "productionFileOne",
  948. label: "产品原图",
  949. itemWidth: 100,
  950. },
  951. {
  952. type: "upload",
  953. listType: "text",
  954. accept: "",
  955. limit: 1,
  956. prop: "prodFileList",
  957. label: "生产plt文件",
  958. },
  959. // {
  960. // type: "slot",
  961. // slotName: "productionFile",
  962. // label: "生产plt文件",
  963. // itemWidth: 100,
  964. // },
  965. {
  966. type: "title1",
  967. title: "单价",
  968. },
  969. {
  970. type: "number",
  971. prop: "price",
  972. label: "销售价",
  973. precision: 2,
  974. min: 0.01,
  975. controls: false,
  976. itemWidth: 50,
  977. disabled: false,
  978. },
  979. {
  980. type: "number",
  981. prop: "factoryPrice",
  982. label: "工厂供货价",
  983. precision: 2,
  984. min: 0.01,
  985. controls: false,
  986. itemWidth: 50,
  987. disabled: false,
  988. },
  989. {
  990. type: "number",
  991. prop: "flatPrice",
  992. label: "平铺价",
  993. precision: 2,
  994. min: 0.01,
  995. controls: false,
  996. itemWidth: 50,
  997. disabled: false,
  998. },
  999. // {
  1000. // type: "number",
  1001. // prop: "businessCostPrice",
  1002. // label: "业务供货价",
  1003. // precision: 2,
  1004. // min: 0.01,
  1005. // controls: false,
  1006. // itemWidth: 50,
  1007. // disabled: false,
  1008. // },
  1009. {
  1010. type: "title1",
  1011. title: "BOM",
  1012. },
  1013. // {
  1014. // type: "select",
  1015. // prop: "rawMaterialId",
  1016. // label: "原材料",
  1017. // itemWidth: 50,
  1018. // data: rawMaterialData.value,
  1019. // filterable: true,
  1020. // disabled: false,
  1021. // fn: (val) => {
  1022. // // let current = rawMaterialData.value.find((x) => x.value == val);
  1023. // // if (current) {
  1024. // // formData.data.price = Number(
  1025. // // parseFloat(
  1026. // // current["length"] * current.width * current.price
  1027. // // ).toFixed(2)
  1028. // // );
  1029. // // }
  1030. // // getPriceData();
  1031. // },
  1032. // },
  1033. {
  1034. type: "slot",
  1035. slotName: "rawMaterialIdSlot",
  1036. label: "",
  1037. itemWidth: 100,
  1038. disabled: true,
  1039. },
  1040. // {
  1041. // type: "input",
  1042. // prop: "rawMaterialSize",
  1043. // label: "原材料尺寸",
  1044. // itemWidth: 50,
  1045. // disabled: true,
  1046. // },
  1047. // {
  1048. // type: "input",
  1049. // prop: "rawMaterialColor",
  1050. // label: "原材料颜色",
  1051. // itemWidth: 50,
  1052. // disabled: true,
  1053. // },
  1054. // {
  1055. // type: "selectInput",
  1056. // prop: "price",
  1057. // selectProp: "currency",
  1058. // label: "销售价",
  1059. // itemWidth: 50,
  1060. // disabledSelect: true,
  1061. // data: currencyData.value,
  1062. // disabled: true,
  1063. // },
  1064. // {
  1065. // type: "select",
  1066. // prop: "technologyId",
  1067. // label: "生产工艺",
  1068. // itemWidth: 50,
  1069. // data: technologyData.value,
  1070. // filterable: true,
  1071. // disabled: false,
  1072. // fn: () => {
  1073. // // getPriceData();
  1074. // },
  1075. // },
  1076. // {
  1077. // type: "input",
  1078. // prop: "spec",
  1079. // label: "规格型号",
  1080. // itemWidth: 50,
  1081. // disabled: false,
  1082. // },
  1083. // {
  1084. // type: "select",
  1085. // prop: "innerPackMethod",
  1086. // label: "内包装方式",
  1087. // required: true,
  1088. // itemWidth: 50,
  1089. // multiple: true,
  1090. // data: innerMethon.value,
  1091. // filterable: true,
  1092. // placeholder: "内包装方式",
  1093. // style: {
  1094. // width: "100%",
  1095. // },
  1096. // disabled: false,
  1097. // },
  1098. // {
  1099. // type: "select",
  1100. // prop: "outerPackMethod",
  1101. // label: "外包装方式",
  1102. // required: true,
  1103. // itemWidth: 50,
  1104. // multiple: true,
  1105. // data: outsideMethon.value,
  1106. // filterable: true,
  1107. // placeholder: "外包装方式",
  1108. // style: {
  1109. // width: "100%",
  1110. // },
  1111. // disabled: false,
  1112. // },
  1113. // {
  1114. // type: "input",
  1115. // itemType: "textarea",
  1116. // prop: "remark",
  1117. // label: "备注",
  1118. // itemWidth: 100,
  1119. // },
  1120. // {
  1121. // type: "title1",
  1122. // title: "辅材",
  1123. // },
  1124. // {
  1125. // type: "slot",
  1126. // slotName: "materialDetail",
  1127. // },
  1128. {
  1129. type: "title1",
  1130. title: "附加工艺要求",
  1131. },
  1132. {
  1133. type: "slot",
  1134. slotName: "technology",
  1135. },
  1136. ];
  1137. });
  1138. const getList = (req) => {
  1139. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  1140. loading.value = true;
  1141. proxy.post("/productInfo/page", sourceList.value.pagination).then(
  1142. (res) => {
  1143. sourceList.value.data = res.rows.map((x) => ({
  1144. ...x,
  1145. fileList: [],
  1146. }));
  1147. sourceList.value.pagination.total = res.total;
  1148. setTimeout(() => {
  1149. loading.value = false;
  1150. }, 200);
  1151. let productIdList = res.rows.map((x) => x.id);
  1152. // 请求文件数据并回显
  1153. if (productIdList.length > 0) {
  1154. // proxy.getFile(productIdList, sourceList.value.data, "id");
  1155. proxy
  1156. .post("/fileInfo/getList", { businessIdList: productIdList })
  1157. .then((fileObj) => {
  1158. for (let i = 0; i < sourceList.value.data.length; i++) {
  1159. const ele = sourceList.value.data[i];
  1160. for (const key in fileObj) {
  1161. if (
  1162. ele.id == key &&
  1163. fileObj[ele.id] &&
  1164. fileObj[ele.id].length > 0
  1165. ) {
  1166. ele.fileList = fileObj[ele.id].filter(
  1167. (x) => x.businessType == "0"
  1168. );
  1169. }
  1170. }
  1171. }
  1172. });
  1173. }
  1174. },
  1175. (err) => {
  1176. loading.value = false;
  1177. }
  1178. );
  1179. };
  1180. const getDict = () => {
  1181. proxy
  1182. .get("/tenantDept/list", {
  1183. pageNum: 1,
  1184. pageSize: 9999,
  1185. keyword: "",
  1186. tenantId: proxy.useUserStore().user.tenantId,
  1187. type: 0,
  1188. })
  1189. .then((res) => {
  1190. companyData.value = res.data.map((x) => ({
  1191. ...x,
  1192. label: x.deptName,
  1193. value: x.deptId,
  1194. }));
  1195. treeDataOne.value = proxy.handleTree(res.data, "deptId");
  1196. });
  1197. };
  1198. getDict();
  1199. const treeChange = (e) => {
  1200. if (e.id != undefined) {
  1201. sourceList.value.pagination.productClassifyId = e.id;
  1202. getList({ productClassifyId: e.id });
  1203. }
  1204. };
  1205. const openModal = () => {
  1206. const productCustomInfoListData = [
  1207. {
  1208. type: 1,
  1209. isCheck: 0,
  1210. isCheckBox: false,
  1211. fileList: [],
  1212. remark: "",
  1213. },
  1214. {
  1215. type: 2,
  1216. isCheck: 0,
  1217. isCheckBox: false,
  1218. fileList: [],
  1219. remark: "",
  1220. },
  1221. {
  1222. type: 3,
  1223. isCheck: 0,
  1224. isCheckBox: false,
  1225. fileList: [],
  1226. remark: "",
  1227. },
  1228. ];
  1229. dialogVisible.value = true;
  1230. modalType.value = "add";
  1231. formData.data = {
  1232. definition: "1",
  1233. fileList: [],
  1234. currency: "",
  1235. prodFileList: [],
  1236. isFold: 0,
  1237. isCustomized: 0,
  1238. packAsk: [],
  1239. productBomDetailList: [],
  1240. productCustomInfoList: productCustomInfoListData,
  1241. };
  1242. // if (currencyData.value && currencyData.value.length > 0) {
  1243. // formData.data.currency = currencyData.value[0].dictKey;
  1244. // }
  1245. };
  1246. const openExcel = () => {
  1247. openExcelDialog.value = true;
  1248. };
  1249. const submitForm = () => {
  1250. formDom.value.handleSubmit((valid) => {
  1251. // if (!formData.data.fileList.length > 0) {
  1252. // return proxy.msgTip("请上传图片", 2);
  1253. // }
  1254. // if (!formData.data.prodFileList.length > 0) {
  1255. // return proxy.msgTip("请上传生产plt文件", 2);
  1256. // }
  1257. // if (
  1258. // !(
  1259. // formData.data.productBomDetailList &&
  1260. // formData.data.productBomDetailList.length > 0
  1261. // )
  1262. // ) {
  1263. // return proxy.msgTip("请添加BOM", 2);
  1264. // } else {
  1265. // let type1 = null;
  1266. // let type3 = null;
  1267. // type1 = formData.data.productBomDetailList.find((x) => x.type == 1);
  1268. // type3 = formData.data.productBomDetailList.find((x) => x.type == 3);
  1269. // if (!(type1 && type3)) {
  1270. // return proxy.msgTip("未选择主材和工艺", 2);
  1271. // }
  1272. // }
  1273. let checkNum = 0;
  1274. for (let i = 0; i < formData.data.productCustomInfoList.length; i++) {
  1275. const ele = formData.data.productCustomInfoList[i];
  1276. ele.isCheck = ele.isCheckBox ? 1 : 0;
  1277. if (ele.isCheckBox) {
  1278. checkNum += 1;
  1279. }
  1280. if (ele.isCheckBox) {
  1281. if (!(ele.fileList && ele.fileList.length > 0)) {
  1282. return proxy.msgTip(`请上传${getLabel(ele.type)}附件`, 2);
  1283. }
  1284. }
  1285. }
  1286. if (checkNum == 0 && formData.data.isCustomized == 1) {
  1287. return proxy.msgTip(`请至少勾选一个定制内容`, 2);
  1288. }
  1289. if (formData.data.packAsk && formData.data.packAsk.length > 0) {
  1290. formData.data.packAsk = formData.data.packAsk.join(",");
  1291. } else {
  1292. formData.data.packAsk = "";
  1293. }
  1294. submitLoading.value = true;
  1295. proxy.post("/productInfo/" + modalType.value, formData.data).then(
  1296. (res) => {
  1297. proxy.msgTip("操作成功", 1);
  1298. dialogVisible.value = false;
  1299. submitLoading.value = false;
  1300. getList();
  1301. },
  1302. (err) => {
  1303. submitLoading.value = false;
  1304. if (formData.data.packAsk) {
  1305. formData.data.packAsk = formData.data.packAsk.split(",");
  1306. } else {
  1307. formData.data.packAsk = [];
  1308. }
  1309. }
  1310. );
  1311. });
  1312. };
  1313. const getTreeList = () => {
  1314. proxy
  1315. .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
  1316. .then((message) => {
  1317. treeListData.value = [
  1318. {
  1319. id: "",
  1320. label: "全部",
  1321. parentId: "",
  1322. children: message,
  1323. },
  1324. ];
  1325. treeData.value = message;
  1326. });
  1327. };
  1328. const getTechnologyData = () => {
  1329. proxy.post("/technology/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  1330. technologyData.value = res.rows;
  1331. });
  1332. };
  1333. const getDtl = (row) => {
  1334. modalType.value = "edit";
  1335. proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
  1336. formData.data = res;
  1337. formData.data.rawMaterialIdLabel =
  1338. res.rawMaterialName + "," + res.rawMaterialCode;
  1339. formData.data.rawMaterialSize = `${res.rawMaterialLength}*${res.rawMaterialWidth}*${res.rawMaterialHeight}`;
  1340. formData.data.rawMaterialList = [
  1341. {
  1342. rawMaterialName: res.rawMaterialName,
  1343. rawMaterialCode: res.rawMaterialCode,
  1344. rawMaterialLength: res.rawMaterialLength,
  1345. rawMaterialWidth: res.rawMaterialWidth,
  1346. rawMaterialHeight: res.rawMaterialHeight,
  1347. rawMaterialColor: res.rawMaterialColor,
  1348. },
  1349. ];
  1350. if (
  1351. formData.data.productCustomInfoList &&
  1352. formData.data.productCustomInfoList.length > 0
  1353. ) {
  1354. formData.data.productCustomInfoList.forEach((x) => {
  1355. x.isCheckBox = x.isCheck == 1;
  1356. if (!x.fileList) {
  1357. x.fileList = [];
  1358. } else {
  1359. x.fileList = x.fileList.map((x) => ({
  1360. ...x,
  1361. url: x.fileUrl,
  1362. name: x.fileName,
  1363. }));
  1364. }
  1365. });
  1366. } else {
  1367. formData.data.productCustomInfoList = [
  1368. {
  1369. type: 1,
  1370. isCheck: 0,
  1371. isCheckBox: false,
  1372. fileList: [],
  1373. remark: "",
  1374. },
  1375. {
  1376. type: 2,
  1377. isCheck: 0,
  1378. isCheckBox: false,
  1379. fileList: [],
  1380. remark: "",
  1381. },
  1382. {
  1383. type: 3,
  1384. isCheck: 0,
  1385. isCheckBox: false,
  1386. fileList: [],
  1387. remark: "",
  1388. },
  1389. ];
  1390. }
  1391. if (formData.data.packAsk) {
  1392. formData.data.packAsk = formData.data.packAsk.split(",");
  1393. }
  1394. formData.data.fileList = row.fileList.map((x) => ({
  1395. ...x,
  1396. url: x.fileUrl,
  1397. name: x.fileName,
  1398. }));
  1399. if (formData.data.fileList.length > 0) {
  1400. formData.data.imageUrl = formData.data.fileList[0].fileUrl;
  1401. }
  1402. proxy
  1403. .post("/fileInfo/getList", { businessIdList: [row.id] })
  1404. .then((fileObj) => {
  1405. if (fileObj[row.id] && fileObj[row.id].length > 0) {
  1406. formData.data.prodFileList = fileObj[row.id]
  1407. .filter((x) => x.businessType == "2")
  1408. .map((item) => {
  1409. return {
  1410. ...item,
  1411. name: item.fileName,
  1412. url: item.fileUrl,
  1413. };
  1414. });
  1415. } else {
  1416. formData.data.prodFileList = [];
  1417. }
  1418. });
  1419. dialogVisible.value = true;
  1420. });
  1421. };
  1422. const rawMaterialData = ref([]);
  1423. const getRawMaterialData = () => {
  1424. proxy.post("/productInfo/page", { productClassifyId: 100 }).then((res) => {
  1425. rawMaterialData.value = res.rows.map((x) => ({
  1426. label:
  1427. x.name +
  1428. "," +
  1429. x.customCode +
  1430. "," +
  1431. `${x["length"]}*${x.width}*${x.height}(cm)` +
  1432. "," +
  1433. x.color,
  1434. value: x.id,
  1435. }));
  1436. // rawMaterialData.value = res.rows.map((x) => ({
  1437. // label: x.name + "," + x.customCode,
  1438. // value: x.id,
  1439. // }));
  1440. });
  1441. };
  1442. getRawMaterialData();
  1443. const bomDialog = ref(false);
  1444. const bomFormDom = ref(null);
  1445. const bomFormOption = reactive({
  1446. disabled: false,
  1447. inline: true,
  1448. labelWidth: 100,
  1449. itemWidth: 100,
  1450. });
  1451. const bomFormConfig = computed(() => {
  1452. return [
  1453. // {
  1454. // type: "title1",
  1455. // title: "BOM 信息",
  1456. // },
  1457. // {
  1458. // type: "select",
  1459. // prop: "rawMaterialId",
  1460. // label: "原材料",
  1461. // itemWidth: 100,
  1462. // data: rawMaterialData.value,
  1463. // filterable: true,
  1464. // disabled: false,
  1465. // },
  1466. // {
  1467. // type: "slot",
  1468. // slotName: "accessories",
  1469. // label: "包材辅料",
  1470. // itemWidth: 100,
  1471. // },
  1472. // {
  1473. // type: "title1",
  1474. // title: "生产工序",
  1475. // },
  1476. {
  1477. type: "slot",
  1478. slotName: "detail",
  1479. label: "",
  1480. },
  1481. ];
  1482. });
  1483. const bomRules = ref({
  1484. rawMaterialId: [
  1485. { required: true, message: "请选择原材料", trigger: "change" },
  1486. ],
  1487. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  1488. });
  1489. const bomSetting = (row) => {
  1490. bomDialog.value = true;
  1491. proxy.post("/productBomInfo/detail", { id: row.id }).then((res) => {
  1492. formData.bomData = {
  1493. name: row.name,
  1494. code: row.customCode,
  1495. id: res.id,
  1496. rawMaterialId: res.rawMaterialId,
  1497. productBomDetailList: [],
  1498. processesList: res.processesList,
  1499. };
  1500. if (res.productBomDetailList && res.productBomDetailList.length > 0) {
  1501. formData.bomData.productBomDetailList = res.productBomDetailList.filter(
  1502. (x) => x.type == 2
  1503. );
  1504. } else {
  1505. formData.bomData.productBomDetailList = [];
  1506. }
  1507. });
  1508. };
  1509. const submitBomForm = () => {
  1510. bomFormDom.value.handleSubmit((valid) => {
  1511. if (!formData.bomData.productBomDetailList.length > 0) {
  1512. return proxy.msgTip("请选择包材辅料", 2);
  1513. }
  1514. formData.bomData.productBomDetailList.push({
  1515. materialId: formData.bomData.rawMaterialId,
  1516. type: 1,
  1517. quantity: 1,
  1518. });
  1519. submitLoading.value = true;
  1520. proxy.post("/productBomInfo/edit", formData.bomData).then(
  1521. (res) => {
  1522. proxy.msgTip("操作成功", 1);
  1523. getList();
  1524. bomDialog.value = false;
  1525. submitLoading.value = false;
  1526. },
  1527. (err) => {
  1528. submitLoading.value = false;
  1529. }
  1530. );
  1531. });
  1532. };
  1533. const openSelectMaterial = ref(false);
  1534. const openType = ref(-1);
  1535. const clickOpenSelectMaterial = (type) => {
  1536. openType.value = type;
  1537. openSelectMaterial.value = true;
  1538. };
  1539. const selectMaterial = (row) => {
  1540. if (openType.value == 1) {
  1541. let flag = formData.data.productBomDetailList.some(
  1542. (x) => x.materialId == row.id
  1543. );
  1544. if (!flag) {
  1545. formData.data.productBomDetailList.push({
  1546. materialId: row.id,
  1547. type: 2,
  1548. materialName: row.name,
  1549. materialCode: row.customCode,
  1550. materialLength: row["length"],
  1551. materialWidth: row.width,
  1552. materialHeight: row.height,
  1553. materialColor: row.color,
  1554. quantity: null,
  1555. standardDosage: 1,
  1556. lossRate: null,
  1557. remark: "",
  1558. });
  1559. proxy.msgTip("选择成功");
  1560. } else {
  1561. proxy.msgTip("该物料已选择", 2);
  1562. }
  1563. } else {
  1564. let flag = formData.bomData.productBomDetailList.some(
  1565. (x) => x.materialId == row.id
  1566. );
  1567. if (!flag) {
  1568. formData.bomData.productBomDetailList.push({
  1569. type: 2,
  1570. materialName: row.name,
  1571. materialCode: row.customCode,
  1572. materialLength: row["length"],
  1573. materialWidth: row.width,
  1574. materialHeight: row.height,
  1575. materialColor: row.color,
  1576. materialId: row.id,
  1577. quantity: null,
  1578. });
  1579. proxy.msgTip("选择成功");
  1580. } else {
  1581. proxy.msgTip("该物料已选择", 2);
  1582. }
  1583. }
  1584. };
  1585. const handleRemove = (index, type) => {
  1586. if (type == 1) {
  1587. formData.data.productBomDetailList.splice(index, 1);
  1588. } else {
  1589. formData.bomData.productBomDetailList.splice(index, 1);
  1590. }
  1591. };
  1592. const handleClickFile = (file) => {
  1593. window.open(file.fileUrl, "_blank");
  1594. };
  1595. const handleProgress = () => {
  1596. excelLoading.value = true;
  1597. };
  1598. const handleError = (err) => {
  1599. proxy.msgTip(`${err},请重试`, 2);
  1600. openExcelDialog.value = false;
  1601. excelLoading.value = false;
  1602. };
  1603. const handleSuccess = (res) => {
  1604. if (res.code != 200) {
  1605. return proxy.msgTip(`${err},请重试`, 2);
  1606. } else {
  1607. proxy.msgTip(`导入成功`, 1);
  1608. openExcelDialog.value = false;
  1609. excelLoading.value = false;
  1610. getList();
  1611. }
  1612. };
  1613. const clickSelect = (item) => {
  1614. proxy.$emit("selectProduct", item);
  1615. };
  1616. const handleClickUpload = async (att, flag) => {
  1617. let res = null;
  1618. let path = "";
  1619. proxy.msgTip("请稍后", 2);
  1620. if (flag) {
  1621. res = await proxy.post("/fileService/createTempFolder");
  1622. if (res && res.path) {
  1623. formData.data[att] = res.path;
  1624. path = res.path;
  1625. }
  1626. } else {
  1627. path = formData.data[att];
  1628. }
  1629. let a = document.createElement("a");
  1630. a.href = "printer://" + `ftp://${import.meta.env.VITE_APP_IP}/` + path + "/";
  1631. a.style.display = "none";
  1632. document.body.appendChild(a);
  1633. a.click();
  1634. document.body.removeChild(a);
  1635. };
  1636. getTechnologyData();
  1637. getTreeList();
  1638. getList();
  1639. const exportExcel = () => {
  1640. proxy.msgTip("正在导出,请稍后", 2);
  1641. proxy
  1642. .postTwo("/productInfo/exportExcel", sourceList.value.pagination)
  1643. .then((res) => {
  1644. proxy.downloadFile(res, "产品数据.xlsx");
  1645. });
  1646. };
  1647. const exportBomExcel = () => {
  1648. proxy.msgTip("正在导出,请稍后", 2);
  1649. proxy
  1650. .postTwo("/productBomInfo/exportExcel", sourceList.value.pagination)
  1651. .then((res) => {
  1652. proxy.downloadFile(res, "产品BOM.xlsx");
  1653. });
  1654. };
  1655. const handleBeforeUploadOne = async (file, index) => {
  1656. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1657. file.id = res.id;
  1658. file.fileUrl = res.fileUrl;
  1659. uploadData.value = res.uploadBody;
  1660. formData.data.productCustomInfoList[index].fileData = res;
  1661. return true;
  1662. };
  1663. const handleSuccessOne = (index) => {
  1664. if (
  1665. formData.data.productCustomInfoList[index].fileData &&
  1666. formData.data.productCustomInfoList[index].fileData.fileUrl
  1667. ) {
  1668. let file = formData.data.productCustomInfoList[index].fileData;
  1669. formData.data.productCustomInfoList[index].fileList.push({
  1670. id: file.id,
  1671. fileName: file.fileName,
  1672. name: file.fileName,
  1673. url: file.fileUrl,
  1674. fileUrl: file.fileUrl,
  1675. });
  1676. formData.data.productCustomInfoList[index].fileData = {};
  1677. }
  1678. };
  1679. const handleRemoveFile = (file, index) => {
  1680. let sonIndex = formData.data.productCustomInfoList[index].fileList.findIndex(
  1681. (x) => x.id == file.id || x.id == file.raw.id
  1682. );
  1683. if (sonIndex > -1) {
  1684. formData.data.productCustomInfoList[index].fileList.splice(sonIndex, 1);
  1685. }
  1686. };
  1687. const onPreviewFile = (file) => {
  1688. if (file && file.fileUrl) {
  1689. window.open(file.fileUrl, "_blank");
  1690. } else {
  1691. window.open(file.raw.fileUrl, "_blank");
  1692. }
  1693. };
  1694. let obj = {
  1695. 1: "定制刀模",
  1696. 2: "定制纹路",
  1697. 3: "定制模具",
  1698. };
  1699. const getLabel = (type) => {
  1700. return obj[type];
  1701. };
  1702. const handleChangeIsCustomized = (val) => {
  1703. return;
  1704. if (val == 1) {
  1705. formData.data.productCustomInfoList = [
  1706. {
  1707. type: 1,
  1708. isCheck: 0,
  1709. isCheckBox: false,
  1710. fileList: [],
  1711. remark: "",
  1712. },
  1713. {
  1714. type: 2,
  1715. isCheck: 0,
  1716. isCheckBox: false,
  1717. fileList: [],
  1718. remark: "",
  1719. },
  1720. {
  1721. type: 3,
  1722. isCheck: 0,
  1723. isCheckBox: false,
  1724. fileList: [],
  1725. remark: "",
  1726. },
  1727. ];
  1728. }
  1729. };
  1730. const openSelectRawMaterial = ref(false);
  1731. const selectRawMaterial = (row) => {
  1732. // formData.data.rawMaterialId = row.id;
  1733. // formData.data.rawMaterialIdLabel = row.name + "," + row.customCode;
  1734. // formData.data.rawMaterialSize = `${row["length"]}*${row.width}*${row.height}`;
  1735. // formData.data.rawMaterialColor = row.color;
  1736. // formData.data.rawMaterialList = [
  1737. // {
  1738. // rawMaterialName: row.name,
  1739. // rawMaterialCode: row.customCode,
  1740. // rawMaterialLength: row["length"],
  1741. // rawMaterialWidth: row.width,
  1742. // rawMaterialHeight: row.height,
  1743. // rawMaterialColor: row.color,
  1744. // },
  1745. // ];
  1746. // openSelectRawMaterial.value = false;
  1747. if (dialogOpenType.value == 1) {
  1748. let flag = formData.data.productBomDetailList.some(
  1749. (x) => x.materialId == row.id
  1750. );
  1751. if (!flag) {
  1752. formData.data.productBomDetailList.unshift({
  1753. materialId: row.id,
  1754. type: 1,
  1755. materialName: row.name,
  1756. materialCode: row.customCode,
  1757. materialLength: row["length"],
  1758. materialWidth: row.width,
  1759. materialHeight: row.height,
  1760. materialColor: row.color,
  1761. quantity: null,
  1762. standardDosage: 1,
  1763. lossRate: null,
  1764. remark: "",
  1765. });
  1766. proxy.msgTip("选择成功");
  1767. } else {
  1768. proxy.msgTip("该物料已选择", 2);
  1769. }
  1770. }
  1771. };
  1772. const openSelectTechnology = ref(false);
  1773. const dialogOpenType = ref(-1);
  1774. const openDialog = (type) => {
  1775. dialogOpenType.value = type;
  1776. if (type == 1) {
  1777. openSelectRawMaterial.value = true;
  1778. }
  1779. if (type == 2) {
  1780. openSelectTechnology.value = true;
  1781. }
  1782. if (type == 3) {
  1783. clickOpenSelectMaterial(1);
  1784. }
  1785. };
  1786. const selectTechnology = (row) => {
  1787. if (
  1788. dialogOpenType.value == 2 &&
  1789. row.processRouteList &&
  1790. row.processRouteList.length > 0
  1791. ) {
  1792. formData.data.technologyId = row.id;
  1793. formData.data.productBomDetailList =
  1794. formData.data.productBomDetailList.filter((x) => x.type != 3);
  1795. let index = formData.data.productBomDetailList.findIndex(
  1796. (x) => x.type == 2
  1797. );
  1798. let arr = row.processRouteList.map((x) => ({
  1799. type: 3,
  1800. materialId: x.id,
  1801. materialName: x.name,
  1802. materialCode: x.code,
  1803. quantity: null,
  1804. standardDosage: 1,
  1805. lossRate: null,
  1806. remark: "",
  1807. }));
  1808. if (index >= 0) {
  1809. formData.data.productBomDetailList.splice(index, 0, ...arr);
  1810. } else {
  1811. formData.data.productBomDetailList.splice(
  1812. formData.data.productBomDetailList.length
  1813. ? formData.data.productBomDetailList.length
  1814. : 0,
  1815. 0,
  1816. ...arr
  1817. );
  1818. }
  1819. openSelectTechnology.value = false;
  1820. return proxy.msgTip("选择成功", 1);
  1821. }
  1822. };
  1823. </script>
  1824. <style lang="scss" scoped>
  1825. .box {
  1826. padding: 10px;
  1827. display: flex;
  1828. justify-content: space-between;
  1829. .tree {
  1830. width: 300px;
  1831. }
  1832. .content {
  1833. width: calc(100% - 310px);
  1834. }
  1835. }
  1836. .pic {
  1837. object-fit: contain;
  1838. width: 50px;
  1839. height: 50px;
  1840. cursor: pointer;
  1841. vertical-align: middle;
  1842. }
  1843. .table {
  1844. border-collapse: collapse;
  1845. border-spacing: 0;
  1846. td {
  1847. text-align: center;
  1848. padding: 2px 4px;
  1849. // padding: 5px 10px;
  1850. }
  1851. }
  1852. .small-title {
  1853. padding-left: 15px;
  1854. margin-bottom: 10px;
  1855. color: #3366ff;
  1856. font-size: 14px;
  1857. }
  1858. :deep(.el-checkbox) {
  1859. margin-right: 0px;
  1860. }
  1861. </style>