index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. <template>
  2. <div style="height: calc(100vh - 114px); overflow-y: auto; overflow-x: hidden">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  4. <template #skuClassifyId>
  5. <div style="width: 100%">
  6. <el-cascader
  7. v-model="formData.data.skuClassifyId"
  8. :options="classifyList"
  9. :props="{ checkStrictly: true, value: 'id', label: 'name', emitPath: false }"
  10. clearable
  11. style="width: 100%" />
  12. </div>
  13. </template>
  14. <template #brand>
  15. <div style="width: 100%">{{ formData.data.brand }}</div>
  16. </template>
  17. <template #specification>
  18. <div style="width: 100%">
  19. <div>
  20. <el-icon style="cursor: pointer; transform: translateY(4px); font-size: 24px; margin-left: 10px" @click="addSpecification"><Plus /></el-icon>
  21. </div>
  22. <el-table
  23. :data="formData.data.skuSpecList"
  24. :row-style="{ height: '35px' }"
  25. header-row-class-name="tableHeader"
  26. :row-key="
  27. (row) => {
  28. return row.id;
  29. }
  30. ">
  31. <el-table-column type="expand">
  32. <template #default="props">
  33. <div style="padding: 10px 20px">
  34. <el-row :gutter="20">
  35. <el-col :span="12">
  36. <div style="margin-bottom: 10px">
  37. <el-button type="primary" size="small" @click="clickSelectCommonPacking(props.$index)">选择常用包装</el-button>
  38. <el-button type="success" size="small" @click="clickSaveCommonPacking(props)">保存常用包装</el-button>
  39. <el-button type="primary" size="small" @click="clickPackingFittings(props)">选择包材配件</el-button>
  40. </div>
  41. <el-table :data="props.row.packagingMaterialList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  42. <el-table-column label="数量" width="120">
  43. <template #default="{ row, $index }">
  44. <el-form-item
  45. :prop="'skuSpecList.' + props.$index + '.packagingMaterialList.' + $index + '.quantity'"
  46. :rules="rulesSpec.quantity"
  47. :inline-message="true"
  48. style="width: 100%">
  49. <el-input-number
  50. onmousewheel="return false;"
  51. v-model="row.quantity"
  52. placeholder="数量"
  53. style="width: 100%"
  54. :controls="false"
  55. :min="0"
  56. :precision="0" />
  57. </el-form-item>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="名称" prop="name" min-width="220" />
  61. <el-table-column label="操作" align="center" fixed="right" width="60">
  62. <template #default="{ $index }">
  63. <el-button type="danger" @click="clickDeletePackingFittings(props.$index, $index)" text>删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. </el-col>
  68. <el-col :span="12">
  69. <div style="margin-bottom: 10px">
  70. <el-button type="primary" size="small" @click="clickExpressPacking(props)">选择快递包装</el-button>
  71. </div>
  72. <el-table :data="props.row.expressPackingList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  73. <el-table-column label="数量" width="120">
  74. <template #default="{ row, $index }">
  75. <el-form-item
  76. :prop="'skuSpecList.' + props.$index + '.expressPackingList.' + $index + '.quantity'"
  77. :rules="rulesSpec.quantity"
  78. :inline-message="true"
  79. style="width: 100%">
  80. <el-input-number
  81. onmousewheel="return false;"
  82. v-model="row.quantity"
  83. placeholder="数量"
  84. style="width: 100%"
  85. :controls="false"
  86. :min="0"
  87. :precision="0" />
  88. </el-form-item>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="名称" prop="name" min-width="220" />
  92. <el-table-column label="操作" align="center" fixed="right" width="60">
  93. <template #default="{ $index }">
  94. <el-button type="danger" @click="clickDeleteExpressPacking(props.$index, $index)" text>删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. </el-col>
  99. </el-row>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="规格图" align="center" width="80">
  104. <template #default="{ row, $index }">
  105. <el-form-item :prop="'skuSpecList.' + $index + '.specImgUrl'">
  106. <el-upload
  107. class="avatar-uploader"
  108. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  109. :data="uploadData"
  110. :show-file-list="false"
  111. :on-success="
  112. (response, uploadFile) => {
  113. return handleSuccess(uploadFile, $index);
  114. }
  115. "
  116. :before-upload="uploadFile">
  117. <el-image v-if="row.specImgUrl" :src="row.specImgUrl" fit="scale-down" class="avatar" />
  118. <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
  119. </el-upload>
  120. </el-form-item>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="设计图" align="center" width="80">
  124. <template #default="{ row, $index }">
  125. <el-form-item :prop="'skuSpecList.' + $index + '.designImgUrl'">
  126. <el-image
  127. v-if="row.designImgUrl"
  128. :src="row.designImgUrl"
  129. fit="scale-down"
  130. style="width: 50px; height: 50px; cursor: pointer"
  131. @click="openFile(row.designImgUrl)" />
  132. </el-form-item>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="品名" min-width="220">
  136. <template #default="{ row, $index }">
  137. <el-form-item :prop="'skuSpecList.' + $index + '.name'" :rules="rulesSpec.name" :inline-message="true" style="width: 100%">
  138. <el-input v-model="row.name" placeholder="请输入品名" />
  139. </el-form-item>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="品号" width="160">
  143. <template #default="{ row, $index }">
  144. <el-form-item :prop="'skuSpecList.' + $index + '.code'" :rules="rulesSpec.code" :inline-message="true" style="width: 100%">
  145. <el-input v-model="row.code" placeholder="请输入品号" />
  146. </el-form-item>
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="图稿文件" width="200">
  150. <template #default="{ row, $index }">
  151. <el-button type="primary" @click="clickDrawingFile($index)" v-if="!row.sharedFolder" text>选择</el-button>
  152. <a
  153. style="color: #409eff; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
  154. @click="clickDrawingFile($index)"
  155. v-else
  156. >{{ row.sharedFolder }}</a
  157. >
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="加工版面" width="140">
  161. <template #default="{ row, $index }">
  162. <el-form-item :prop="'skuSpecList.' + $index + '.machinedPanel'" style="width: 100%">
  163. <el-select v-model="row.machinedPanel" placeholder="加工版面" clearable>
  164. <el-option v-for="item in useUserStore().allDict['processing_layout']" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  165. </el-select>
  166. </el-form-item>
  167. </template>
  168. </el-table-column>
  169. <el-table-column label="尺寸(长宽高,cm)" align="center" width="260">
  170. <template #default="{ row, $index }">
  171. <el-row>
  172. <el-col :span="8">
  173. <el-form-item :prop="'skuSpecList.' + $index + '.length'" :rules="rulesSpec.length" :inline-message="true" style="width: 100%">
  174. <el-input-number
  175. onmousewheel="return false;"
  176. v-model="row.length"
  177. placeholder="长"
  178. style="width: 100%"
  179. :controls="false"
  180. :min="0"
  181. :precision="2" />
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="8">
  185. <el-form-item :prop="'skuSpecList.' + $index + '.width'" :rules="rulesSpec.width" :inline-message="true" style="width: 100%">
  186. <el-input-number
  187. onmousewheel="return false;"
  188. v-model="row.width"
  189. placeholder="宽"
  190. style="width: 100%"
  191. :controls="false"
  192. :min="0"
  193. :precision="2" />
  194. </el-form-item>
  195. </el-col>
  196. <el-col :span="8">
  197. <el-form-item :prop="'skuSpecList.' + $index + '.height'" :rules="rulesSpec.height" :inline-message="true" style="width: 100%">
  198. <el-input-number
  199. onmousewheel="return false;"
  200. v-model="row.height"
  201. placeholder="高"
  202. style="width: 100%"
  203. :controls="false"
  204. :min="0"
  205. :precision="2" />
  206. </el-form-item>
  207. </el-col>
  208. </el-row>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="净重(g)" width="120">
  212. <template #default="{ row, $index }">
  213. <el-form-item :prop="'skuSpecList.' + $index + '.netWeight'" :rules="rulesSpec.netWeight" :inline-message="true" style="width: 100%">
  214. <el-input-number
  215. onmousewheel="return false;"
  216. v-model="row.netWeight"
  217. placeholder="净重"
  218. style="width: 100%"
  219. :controls="false"
  220. :min="0"
  221. :precision="2" />
  222. </el-form-item>
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="BOM" align="left" width="160">
  226. <template #default="{ row, $index }">
  227. <el-button
  228. v-if="!row.bomSpecId"
  229. type="primary"
  230. size="small"
  231. @click="handleOpen($index)"
  232. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  233. 选择BOM
  234. </el-button>
  235. <div style="width: 100%; display: flex; align-items: center" v-else>
  236. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemoveBOM($index)"><Remove /></el-icon>
  237. <span>{{ row.bomSpecCode }}</span>
  238. </div>
  239. </template>
  240. </el-table-column>
  241. <el-table-column label="操作" align="center" fixed="right" width="60">
  242. <template #default="{ $index }">
  243. <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
  244. </template>
  245. </el-table-column>
  246. </el-table>
  247. </div>
  248. </template>
  249. <template #mainImgUrl>
  250. <div style="width: 100%">
  251. <div style="color: #aaaaaa">图片不超过5M,支持JPEG、JPG、PNG格式;</div>
  252. <div style="color: #aaaaaa">建议主图大于640*640,主题鲜明、图片清晰、提升买家满意度;</div>
  253. <el-upload
  254. class="avatar-uploader-main"
  255. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  256. :data="uploadMainData"
  257. :show-file-list="false"
  258. :on-success="handleMainSuccess"
  259. :before-upload="uploadMainFile">
  260. <el-image v-if="formData.data.mainImgUrl" :src="formData.data.mainImgUrl" fit="scale-down" class="avatar" />
  261. <el-icon v-else class="avatar-uploader-main-icon"><Plus /></el-icon>
  262. </el-upload>
  263. </div>
  264. </template>
  265. <template #detailText>
  266. <div style="width: 100%">
  267. <div v-if="props.detailStatus">
  268. <div v-html="getStyle(formData.data.detailText)"></div>
  269. </div>
  270. <Editor v-else :value="formData.data.detailText" @updateValue="updateValue" ref="editor" />
  271. </div>
  272. </template>
  273. </byForm>
  274. <div style="text-align: center; margin: 10px">
  275. <el-button v-if="props.detailStatus" @click="clickCancel()" size="large">关 闭</el-button>
  276. <el-button v-if="!props.detailStatus" @click="clickCancel()" size="large">取 消</el-button>
  277. <el-button type="primary" @click="submitForm()" v-if="!props.detailStatus" size="large" v-preReClick>确 定</el-button>
  278. </div>
  279. <el-dialog title="选择BOM" v-if="openBOM" v-model="openBOM" width="84%">
  280. <SelectBOM :selectStatus="true" @selectBOM="selectBOM"></SelectBOM>
  281. <template #footer>
  282. <el-button @click="openBOM = false" size="large">关 闭</el-button>
  283. </template>
  284. </el-dialog>
  285. <el-dialog title="选择包材配件" v-if="openPackingFittings" v-model="openPackingFittings" width="84%">
  286. <SelectBOM :selectStatus="true" :bomClassifyIdList="[2, 3]" @selectBOM="selectPackingFittings"></SelectBOM>
  287. <template #footer>
  288. <el-button @click="openPackingFittings = false" size="large">关 闭</el-button>
  289. </template>
  290. </el-dialog>
  291. <el-dialog title="选择快递包装" v-if="openExpressPacking" v-model="openExpressPacking" width="84%">
  292. <SelectBOM :selectStatus="true" :expressStatus="true" @selectBOM="selectExpressPacking"></SelectBOM>
  293. <template #footer>
  294. <el-button @click="openExpressPacking = false" size="large">关 闭</el-button>
  295. </template>
  296. </el-dialog>
  297. <el-dialog title="选择图稿" v-if="openDrawingFile" v-model="openDrawingFile" width="70%">
  298. <SelectPicture @selectPic="selectPic"></SelectPicture>
  299. <template #footer>
  300. <el-button @click="openDrawingFile = false" size="large">关 闭</el-button>
  301. </template>
  302. </el-dialog>
  303. <el-dialog title="保存常用组合" v-if="openAssembly" v-model="openAssembly" width="500">
  304. <el-form :model="formShippingPackage.data" :rules="rulesAssembly" ref="assembly">
  305. <el-form-item label="组合名称" prop="name">
  306. <el-input v-model="formShippingPackage.data.name" placeholder="请输入组合名称" />
  307. </el-form-item>
  308. </el-form>
  309. <template #footer>
  310. <el-button @click="openAssembly = false">关 闭</el-button>
  311. <el-button type="primary" @click="submitAssembly" v-preReClick>保 存</el-button>
  312. </template>
  313. </el-dialog>
  314. <el-dialog title="选择常用组合" v-if="openSelectAssembly" v-model="openSelectAssembly" width="80%">
  315. <CommonPacking @selectAssembly="selectAssembly"></CommonPacking>
  316. <template #footer>
  317. <el-button @click="openSelectAssembly = false">关 闭</el-button>
  318. </template>
  319. </el-dialog>
  320. </div>
  321. </template>
  322. <script setup>
  323. import byForm from "/src/components/byForm/index";
  324. import { ElMessage } from "element-plus";
  325. import Editor from "/src/components/Editor/index.vue";
  326. import SelectBOM from "/src/views/group/BOM/management/index";
  327. import SelectPicture from "/src/components/select-picture/index.vue";
  328. import CommonPacking from "/src/components/makeProduct/commonPacking/index.vue";
  329. const { proxy } = getCurrentInstance();
  330. const emit = defineEmits(["clickCancel"]);
  331. const submit = ref(null);
  332. const formOption = reactive({
  333. inline: true,
  334. labelWidth: "120px",
  335. itemWidth: 100,
  336. rules: [],
  337. labelPosition: "right",
  338. });
  339. const formData = reactive({
  340. data: {
  341. brand: "胜德科技",
  342. type: 1,
  343. source: 1,
  344. craftProductionLineId: "1",
  345. mainImgUrl: "",
  346. detailText: "",
  347. skuSpecList: [
  348. {
  349. specImgUrl: "",
  350. designImgUrl: "",
  351. name: "",
  352. code: "",
  353. barCode: "",
  354. machinedPanel: "",
  355. length: undefined,
  356. width: undefined,
  357. height: undefined,
  358. netWeight: undefined,
  359. sharedFolder: "",
  360. artworkLibraryId: "0",
  361. bomSpecId: "",
  362. remark: "",
  363. packagingMaterialList: [],
  364. expressPackingList: [],
  365. },
  366. ],
  367. },
  368. });
  369. const formConfig = computed(() => {
  370. return [
  371. {
  372. type: "title",
  373. title: "基本信息",
  374. label: "",
  375. },
  376. {
  377. type: "slot",
  378. prop: "skuClassifyId",
  379. slotName: "skuClassifyId",
  380. label: "类目",
  381. itemWidth: 50,
  382. },
  383. {
  384. type: "input",
  385. prop: "barCode",
  386. label: "条码",
  387. itemType: "text",
  388. itemWidth: 50,
  389. },
  390. {
  391. type: "input",
  392. prop: "groupItemNumber",
  393. label: "群组品号",
  394. itemType: "text",
  395. itemWidth: 50,
  396. },
  397. {
  398. type: "input",
  399. prop: "code",
  400. label: "编码",
  401. itemType: "text",
  402. itemWidth: 50,
  403. },
  404. {
  405. type: "input",
  406. prop: "name",
  407. label: "名称",
  408. itemType: "text",
  409. },
  410. {
  411. type: "title",
  412. title: "材质特征",
  413. label: "",
  414. },
  415. {
  416. type: "slot",
  417. slotName: "brand",
  418. label: "品牌",
  419. },
  420. {
  421. type: "input",
  422. prop: "modelNumber",
  423. label: "型号",
  424. itemType: "text",
  425. itemWidth: 50,
  426. },
  427. {
  428. type: "input",
  429. prop: "material",
  430. label: "材质",
  431. itemType: "text",
  432. itemWidth: 50,
  433. },
  434. {
  435. type: "slot",
  436. slotName: "specification",
  437. label: "规格",
  438. },
  439. {
  440. type: "title",
  441. title: "工艺路线",
  442. label: "",
  443. },
  444. {
  445. type: "select",
  446. label: "工艺路线",
  447. prop: "craftProductionLineId",
  448. data: [],
  449. itemWidth: 50,
  450. },
  451. {
  452. type: "title",
  453. title: "图片介绍",
  454. label: "",
  455. },
  456. {
  457. type: "slot",
  458. slotName: "mainImgUrl",
  459. label: "主图",
  460. },
  461. {
  462. type: "slot",
  463. slotName: "detailText",
  464. label: "详情描述",
  465. },
  466. ];
  467. });
  468. const rules = ref({
  469. groupItemNumber: [{ required: true, message: "请输入群组品号", trigger: "blur" }],
  470. code: [{ required: true, message: "请输入编码", trigger: "blur" }],
  471. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  472. });
  473. const rulesSpec = ref({
  474. code: [{ required: true, message: "请输入品号", trigger: "blur" }],
  475. name: [{ required: true, message: "请输入品名", trigger: "blur" }],
  476. length: [{ required: true, message: "请输入长", trigger: "blur" }],
  477. width: [{ required: true, message: "请输入宽", trigger: "blur" }],
  478. height: [{ required: true, message: "请输入高", trigger: "blur" }],
  479. netWeight: [{ required: true, message: "请输入净重", trigger: "blur" }],
  480. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  481. });
  482. const classifyList = ref([]);
  483. const getBomClassify = () => {
  484. proxy.post("/skuClassify/tree", {}).then((res) => {
  485. classifyList.value = res;
  486. });
  487. };
  488. getBomClassify();
  489. const addSpecification = () => {
  490. if (!props.detailStatus) {
  491. if (formData.data.skuSpecList && formData.data.skuSpecList.length > 0) {
  492. formData.data.skuSpecList.push({
  493. specImgUrl: "",
  494. designImgUrl: "",
  495. name: "",
  496. code: "",
  497. barCode: "",
  498. machinedPanel: "",
  499. length: undefined,
  500. width: undefined,
  501. height: undefined,
  502. netWeight: undefined,
  503. sharedFolder: "",
  504. artworkLibraryId: "0",
  505. bomSpecId: "",
  506. remark: "",
  507. packagingMaterialList: [],
  508. expressPackingList: [],
  509. });
  510. } else {
  511. formData.data.skuSpecList = [
  512. {
  513. specImgUrl: "",
  514. designImgUrl: "",
  515. name: "",
  516. code: "",
  517. barCode: "",
  518. machinedPanel: "",
  519. length: undefined,
  520. width: undefined,
  521. height: undefined,
  522. netWeight: undefined,
  523. sharedFolder: "",
  524. artworkLibraryId: "0",
  525. bomSpecId: "",
  526. remark: "",
  527. packagingMaterialList: [],
  528. expressPackingList: [],
  529. },
  530. ];
  531. }
  532. }
  533. };
  534. const uploadData = ref({});
  535. const uploadFile = async (file) => {
  536. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  537. uploadData.value = res.uploadBody;
  538. file.id = res.id;
  539. file.fileName = res.fileName;
  540. file.fileUrl = res.fileUrl;
  541. return true;
  542. };
  543. const handleSuccess = (uploadFile, index) => {
  544. formData.data.skuSpecList[index].specImgUrl = uploadFile.raw.fileUrl;
  545. };
  546. const clickDelete = (index) => {
  547. formData.data.skuSpecList.splice(index, 1);
  548. };
  549. const editor = ref(null);
  550. const updateValue = (val) => {
  551. formData.data.detailText = val;
  552. };
  553. const uploadMainData = ref({});
  554. const uploadMainFile = async (file) => {
  555. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  556. uploadMainData.value = res.uploadBody;
  557. file.id = res.id;
  558. file.fileName = res.fileName;
  559. file.fileUrl = res.fileUrl;
  560. return true;
  561. };
  562. const handleMainSuccess = (response, uploadFile) => {
  563. formData.data.mainImgUrl = uploadFile.raw.fileUrl;
  564. };
  565. const submitForm = () => {
  566. submit.value.handleSubmit(() => {
  567. if (formData.data.skuSpecList && formData.data.skuSpecList.length > 0) {
  568. let type = "add";
  569. if (formData.data.id) {
  570. type = "edit";
  571. }
  572. proxy.post("/sku/" + type, formData.data).then(() => {
  573. ElMessage({
  574. message: type == "add" ? "添加成功" : "编辑成功",
  575. type: "success",
  576. });
  577. emit("clickCancel", true);
  578. });
  579. } else {
  580. return ElMessage("请添加规格");
  581. }
  582. });
  583. };
  584. const clickCancel = () => {
  585. emit("clickCancel", false);
  586. };
  587. const props = defineProps({
  588. rowData: Object,
  589. detailStatus: Boolean,
  590. });
  591. onMounted(() => {
  592. formOption.disabled = props.detailStatus;
  593. if (props.rowData && props.rowData.id) {
  594. proxy.post("/sku/detail", { id: props.rowData.id }).then((res) => {
  595. for (var text in res) {
  596. formData.data[text] = res[text];
  597. }
  598. if (!props.detailStatus) {
  599. editor.value.changeHtml(formData.data.detailText);
  600. }
  601. });
  602. }
  603. });
  604. const getStyle = (text) => {
  605. if (text) {
  606. return text.replace(/\n|\r\n/g, "<br>");
  607. } else {
  608. return "";
  609. }
  610. };
  611. const rowIndex = ref(null);
  612. const openBOM = ref(false);
  613. const handleOpen = (index) => {
  614. rowIndex.value = index;
  615. openBOM.value = true;
  616. };
  617. const selectBOM = (item) => {
  618. if (item.id) {
  619. formData.data.skuSpecList[rowIndex.value].bomSpecId = item.id;
  620. formData.data.skuSpecList[rowIndex.value].bomSpecCode = item.code;
  621. formData.data.skuSpecList[rowIndex.value].length = item.length;
  622. formData.data.skuSpecList[rowIndex.value].width = item.width;
  623. formData.data.skuSpecList[rowIndex.value].height = item.height;
  624. formData.data.skuSpecList[rowIndex.value].netWeight = item.netWeight;
  625. ElMessage({ message: "选择完成", type: "success" });
  626. openBOM.value = false;
  627. proxy.post("/skuDefaultPackageSpec/getPackList", { skuId: formData.data.id, spec: item.length + "*" + item.width + "*" + item.height }).then((res) => {
  628. if (res && res.length > 0) {
  629. formData.data.skuSpecList[rowIndex.value].packagingMaterialList = res.map((val) => {
  630. return {
  631. bomSpecId: val.bomSpecId,
  632. quantity: 1,
  633. name: val.bomSpecName,
  634. };
  635. });
  636. } else {
  637. formData.data.skuSpecList[rowIndex.value].packagingMaterialList = [];
  638. }
  639. ElMessage({ message: "根据规格尺寸替换包材配件完成", type: "success" });
  640. });
  641. }
  642. };
  643. const clickRemoveBOM = (index) => {
  644. formData.data.skuSpecList[index].bomSpecId = "";
  645. formData.data.skuSpecList[index].bomSpecName = "";
  646. };
  647. const openPackingFittings = ref(false);
  648. const clickPackingFittings = (item) => {
  649. rowIndex.value = item.$index;
  650. openPackingFittings.value = true;
  651. };
  652. const openExpressPacking = ref(false);
  653. const clickExpressPacking = (item) => {
  654. rowIndex.value = item.$index;
  655. openExpressPacking.value = true;
  656. };
  657. const selectPackingFittings = (data) => {
  658. if (formData.data.skuSpecList[rowIndex.value].packagingMaterialList && formData.data.skuSpecList[rowIndex.value].packagingMaterialList.length > 0) {
  659. let list = formData.data.skuSpecList[rowIndex.value].packagingMaterialList.filter((item) => item.bomSpecId === data.id);
  660. if (list && list.length > 0) {
  661. return ElMessage("包材配件已添加");
  662. }
  663. formData.data.skuSpecList[rowIndex.value].packagingMaterialList.push({
  664. bomSpecId: data.id,
  665. quantity: 1,
  666. name: data.name,
  667. });
  668. } else {
  669. formData.data.skuSpecList[rowIndex.value].packagingMaterialList = [
  670. {
  671. bomSpecId: data.id,
  672. quantity: 1,
  673. name: data.name,
  674. },
  675. ];
  676. }
  677. ElMessage({ message: "添加成功", type: "success" });
  678. };
  679. const selectExpressPacking = (data) => {
  680. if (formData.data.skuSpecList[rowIndex.value].expressPackingList && formData.data.skuSpecList[rowIndex.value].expressPackingList.length > 0) {
  681. let list = formData.data.skuSpecList[rowIndex.value].expressPackingList.filter((item) => item.bomSpecId === data.id);
  682. if (list && list.length > 0) {
  683. return ElMessage("快递包材已添加");
  684. }
  685. formData.data.skuSpecList[rowIndex.value].expressPackingList.push({
  686. bomSpecId: data.id,
  687. quantity: 1,
  688. name: data.name,
  689. });
  690. } else {
  691. formData.data.skuSpecList[rowIndex.value].expressPackingList = [
  692. {
  693. bomSpecId: data.id,
  694. quantity: 1,
  695. name: data.name,
  696. },
  697. ];
  698. }
  699. ElMessage({ message: "添加成功", type: "success" });
  700. };
  701. const clickDeletePackingFittings = (index, indexTwo) => {
  702. formData.data.skuSpecList[index].packagingMaterialList.splice(indexTwo, 1);
  703. };
  704. const clickDeleteExpressPacking = (index, indexTwo) => {
  705. formData.data.skuSpecList[index].expressPackingList.splice(indexTwo, 1);
  706. };
  707. const drawingFileIndex = ref(0);
  708. const openDrawingFile = ref(false);
  709. const clickDrawingFile = (index) => {
  710. drawingFileIndex.value = index;
  711. openDrawingFile.value = true;
  712. };
  713. const selectPic = (row) => {
  714. formData.data.skuSpecList[drawingFileIndex.value].sharedFolder = row.fileUrl;
  715. formData.data.skuSpecList[drawingFileIndex.value].designImgUrl = row.imgUrl;
  716. formData.data.skuSpecList[drawingFileIndex.value].artworkLibraryId = row.id;
  717. ElMessage({ message: "选择完成", type: "success" });
  718. openDrawingFile.value = false;
  719. };
  720. const openFile = (path) => {
  721. window.open(path);
  722. };
  723. const packingIndex = ref(0);
  724. const openSelectAssembly = ref(false);
  725. const clickSelectCommonPacking = (index) => {
  726. packingIndex.value = index;
  727. openSelectAssembly.value = true;
  728. };
  729. const selectAssembly = (item) => {
  730. if (item.packagingMaterialList && item.packagingMaterialList.length > 0) {
  731. formData.data.skuSpecList[packingIndex.value].packagingMaterialList = item.packagingMaterialList.map((row) => {
  732. return {
  733. bomSpecId: row.bomSpecId,
  734. quantity: row.quantity,
  735. name: row.bomSpecName,
  736. };
  737. });
  738. } else {
  739. formData.data.skuSpecList[packingIndex.value].packagingMaterialList = [];
  740. }
  741. if (item.expressPackingList && item.expressPackingList.length > 0) {
  742. formData.data.skuSpecList[packingIndex.value].expressPackingList = item.expressPackingList.map((row) => {
  743. return {
  744. bomSpecId: row.bomSpecId,
  745. quantity: row.quantity,
  746. name: row.bomSpecName,
  747. };
  748. });
  749. } else {
  750. formData.data.skuSpecList[packingIndex.value].expressPackingList = [];
  751. }
  752. ElMessage({ message: "选择完成", type: "success" });
  753. openSelectAssembly.value = false;
  754. };
  755. const openAssembly = ref(false);
  756. const rulesAssembly = ref({
  757. name: [{ required: true, message: "请输入组合名称", trigger: "blur" }],
  758. });
  759. const formShippingPackage = reactive({
  760. data: {
  761. name: "",
  762. commonPackingBomDetailList: [],
  763. },
  764. });
  765. const clickSaveCommonPacking = (item) => {
  766. formShippingPackage.data = {
  767. name: "",
  768. commonPackingBomDetailList: [],
  769. };
  770. if (item.row.packagingMaterialList && item.row.packagingMaterialList.length > 0) {
  771. formShippingPackage.data.commonPackingBomDetailList = formShippingPackage.data.commonPackingBomDetailList.concat(
  772. item.row.packagingMaterialList.map((row) => {
  773. return {
  774. bomSpecId: row.bomSpecId,
  775. quantity: row.quantity,
  776. type: 1,
  777. };
  778. })
  779. );
  780. }
  781. if (item.row.expressPackingList && item.row.expressPackingList.length > 0) {
  782. formShippingPackage.data.commonPackingBomDetailList = formShippingPackage.data.commonPackingBomDetailList.concat(
  783. item.row.expressPackingList.map((row) => {
  784. return {
  785. bomSpecId: row.bomSpecId,
  786. quantity: row.quantity,
  787. type: 2,
  788. };
  789. })
  790. );
  791. }
  792. if (formShippingPackage.data.commonPackingBomDetailList && formShippingPackage.data.commonPackingBomDetailList.length > 0) {
  793. for (let i = 0; i < formShippingPackage.data.commonPackingBomDetailList.length; i++) {
  794. const element = formShippingPackage.data.commonPackingBomDetailList[i];
  795. if (!element.quantity) {
  796. return ElMessage("请填写数量");
  797. }
  798. }
  799. } else {
  800. return ElMessage("请先添加包材配件和快递包装");
  801. }
  802. openAssembly.value = true;
  803. };
  804. const submitAssembly = () => {
  805. proxy.$refs.assembly.validate((valid) => {
  806. if (valid) {
  807. proxy.post("/commonPackingBom/add", formShippingPackage.data).then(() => {
  808. ElMessage({ message: "保存成功!", type: "success" });
  809. openAssembly.value = false;
  810. });
  811. }
  812. });
  813. };
  814. </script>
  815. <style lang="scss" scoped>
  816. .avatar-uploader .avatar {
  817. width: 50px;
  818. height: 50px;
  819. display: block;
  820. background-color: black;
  821. }
  822. .avatar-uploader .el-upload {
  823. border: 1px dashed var(--el-border-color);
  824. border-radius: 6px;
  825. cursor: pointer;
  826. position: relative;
  827. overflow: hidden;
  828. transition: var(--el-transition-duration-fast);
  829. }
  830. .avatar-uploader .el-upload:hover {
  831. border-color: var(--el-color-primary);
  832. }
  833. .el-icon.avatar-uploader-icon {
  834. font-size: 28px;
  835. color: #8c939d;
  836. width: 50px;
  837. height: 50px;
  838. text-align: center;
  839. border: 1px dashed var(--el-border-color);
  840. }
  841. ::v-deep(.el-input-number .el-input__inner) {
  842. text-align: left;
  843. }
  844. .avatar-uploader-main .avatar {
  845. width: 148px;
  846. height: 148px;
  847. display: block;
  848. background-color: black;
  849. }
  850. .avatar-uploader-main .el-upload {
  851. border: 1px dashed var(--el-border-color);
  852. border-radius: 6px;
  853. cursor: pointer;
  854. position: relative;
  855. overflow: hidden;
  856. transition: var(--el-transition-duration-fast);
  857. }
  858. .avatar-uploader-main .el-upload:hover {
  859. border-color: var(--el-color-primary);
  860. }
  861. .el-icon.avatar-uploader-main-icon {
  862. font-size: 28px;
  863. color: #8c939d;
  864. width: 148px;
  865. height: 148px;
  866. text-align: center;
  867. border: 1px dashed var(--el-border-color);
  868. }
  869. :deep(.el-dialog) {
  870. margin-top: 10px !important;
  871. margin-bottom: 10px !important;
  872. }
  873. </style>