index.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723
  1. <template>
  2. <div class="my-container">
  3. <transition-group name="fade" style="position: relative;width: 100%;display: flex;">
  4. <div class="bill-left" v-show="isShow==='home'" key="item">
  5. <div class="bill-tab">
  6. <div class="bill-title">导航</div>
  7. <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
  8. </div>
  9. </div>
  10. <div class="bill-main" v-show="isShow==='home'" key="item2">
  11. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  12. @resert="onRefresh" @clickHandle="clickHandle" @detail="getDetail" @onRefresh="onRefresh" />
  13. </div>
  14. <!-- 新增/编辑 -->
  15. <div class="detil" v-show="isShow==='add'" key="item3">
  16. <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
  17. <div class="box-shadow">
  18. <by-form :propConfig="formConfig" ref="form">
  19. <template v-slot:description>
  20. <el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="textarea">
  21. </el-input>
  22. </template>
  23. <template v-slot:tags>
  24. <el-tag style="margin-right: 16px;" :disable-transitions="true" v-for="(item,index) of tagsData"
  25. :key="index" closable @close="handleClose2(index)">
  26. {{item}}
  27. </el-tag>
  28. <by-input class="input-new-tag" ref="tagsValue" style="width: 150px;"></by-input>
  29. <el-button class="button-new-tag" @click="getTagsValue">添加</el-button>
  30. </template>
  31. <template v-slot:status>
  32. <el-radio v-model="status" :label="0">启用</el-radio>
  33. <el-radio v-model="status" :label="1">备用</el-radio>
  34. <el-radio v-model="status" :label="2">禁用</el-radio>
  35. </template>
  36. <template v-slot:ismakeup>
  37. <el-radio v-model="ismakeup" :label="0">是</el-radio>
  38. <el-radio v-model="ismakeup" :label="1">否</el-radio>
  39. <el-button v-show="ismakeup===0" @click="openMakeup">选择商品</el-button>
  40. </template>
  41. <template v-slot:makeupTable>
  42. <div v-if="ismakeup===0">
  43. <by-table :propConfig="makeupTable" ref="makeupTable"></by-table>
  44. </div>
  45. </template>
  46. <template v-slot:issued>
  47. <el-radio v-model="issued" :label="0">是</el-radio>
  48. <el-radio v-model="issued" :label="1">否</el-radio>
  49. </template>
  50. <template v-slot:materialSpec>
  51. <el-radio v-model="materialSpec" :label="0" @input="changeSingle">单规格</el-radio>
  52. <el-radio v-model="materialSpec" :label="1" @input="changeSingle">多规格</el-radio>
  53. </template>
  54. <template v-slot:attributeName>
  55. <div v-if="isSingle" key="item4">
  56. <by-table :propConfig="singleTable" @onChangeRow="getInputValue" ref="singeTable">
  57. <template v-slot:stock="{row}">
  58. <vxe-input v-if="!isEdit" v-model="row.stock" size="mini" type="integer"></vxe-input>
  59. <span v-else>{{ row.stock }}</span>
  60. </template>
  61. </by-table>
  62. </div>
  63. <div v-if="!isSingle" key="item5">
  64. <el-select :value="selectValue" clearable placeholder="请选择" style="width: 19.5%;"
  65. @input="getSelectValue">
  66. <el-option v-for="item in selectList" :key="item.value" :label="item.name" :value="item.id">
  67. </el-option>
  68. </el-select>
  69. <div class="by-tab" key="item6">
  70. <div v-for="(item,index) of attributeList" :key="index">
  71. <div class="tab-title">{{item.title}} <i class="el-icon-circle-close"
  72. @click="closeGroup(index)"></i>
  73. </div>
  74. <el-tag class="item-tab" :disable-transitions="true" :key="i" v-for="(tag,i) of item.list" closable
  75. @close="handleClose(tag,index)">
  76. {{tag}}
  77. </el-tag>
  78. <by-input class="input-new-tag" :ref="'getValue_'+index"></by-input>
  79. <el-button class="button-new-tag" @click="showInput(index)">添加</el-button>
  80. </div>
  81. <div style="margin: 20px 0;" v-if="!isAdd" key="item7">
  82. <div class="el-button mr15 el-button--primary el-button--small" @click="isAdd=true">添加新规格</div>
  83. </div>
  84. <div style="display: flex;margin: 20px 0;" v-else key='item8'>
  85. <div class="flex-item">
  86. <label>规格:</label>
  87. <div class="el-input el-input--small" style="width: 250px;">
  88. <input type="text" v-model="norms" placeholder="请输入规格" class="el-input__inner">
  89. </div>
  90. </div>
  91. <div class="flex-item">
  92. <label>规格值:</label>
  93. <div class="el-input el-input--small" style="width: 250px;">
  94. <input type="text" v-model="normsValue" placeholder="请输入规格值" class="el-input__inner">
  95. </div>
  96. </div>
  97. <div @click="doComfirm" class="el-button el-button--primary el-button--small">确定</div>
  98. <div @click="isAdd=false" class="el-button el-button--danger el-button--small">取消</div>
  99. </div>
  100. <div>
  101. <by-table :propConfig="tableConfig" @onChangeRow="getInputValue" ref="table">
  102. <template v-slot:stock="{row}">
  103. <vxe-input v-if="!isEdit" v-model="row.stock" size="mini" type="integer"></vxe-input>
  104. <span v-else>{{ row.stock }}</span>
  105. </template>
  106. </by-table>
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. </by-form>
  112. </div>
  113. </div>
  114. </transition-group>
  115. <!-- 选择物料 -->
  116. <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
  117. <!-- <productDialog ref="product" :mulit="true" @confirm="confirmProduct" /> -->
  118. </div>
  119. </template>
  120. <script lang="ts">
  121. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  122. import api from '@/api/currency'
  123. import other from '@/api/other'
  124. import ForTab from "@/components/ForTab/index.vue";
  125. import productModal from "../orderTask/components/productModal.vue";
  126. import brandType from "./components/brandType.vue";
  127. @Component({ components: { ForTab, productModal, brandType } })
  128. export default class productManagement extends Vue {
  129. tagsData : any = [] // 标签值
  130. isShow = 'home'
  131. isEdit = true
  132. editInfo : any = ''
  133. isSingle : any = true
  134. timeNum = 0;
  135. timer : any = null
  136. materialSpec : any = 0
  137. status : any = 0
  138. ismakeup : any = 1
  139. issued : any = 0
  140. textarea : any = ''
  141. categoryIds : any = ''
  142. selectList = []
  143. selectValue = ''
  144. // tab
  145. singeTable : any = ''
  146. setTableConfig : any = ''
  147. towTable : any = ''
  148. attributeList : any = [] // 物料属性规格
  149. inputValue : any = ''
  150. norms : any = ''
  151. normsValue : any = ''
  152. isAdd : any = false
  153. skuRuleList : any = ''
  154. tableList : any = ''
  155. attributeId : any = ''
  156. intercept : any = ''
  157. makeupList : any = [] // 组合商品列表
  158. // tab
  159. toolConfig = {
  160. tools: {
  161. return: true,
  162. save: true,
  163. }
  164. }
  165. treeConfig = {
  166. attr: {
  167. retConfig: {
  168. id: 'id',
  169. },
  170. defaultExpandAll: true,
  171. label: 'name',
  172. resType: 'data'
  173. },
  174. request: {
  175. url: '/maindata/maindataMaterialCategory/treeUseList',
  176. method: 'GET'
  177. }
  178. }
  179. singleTable : any = {
  180. attr: {
  181. size: 'mini',
  182. align: 'center',
  183. },
  184. columns: [
  185. {
  186. width: '150px',
  187. title: '标题',
  188. field: 'skuTitle',
  189. component: 'by-input',
  190. compConfig: {
  191. attr: {
  192. size: 'mini',
  193. placeholder: ' '
  194. },
  195. }
  196. },
  197. {
  198. width: '120px',
  199. title: '副标题',
  200. field: 'skuSubtitle',
  201. component: 'by-input',
  202. compConfig: {
  203. attr: {
  204. size: 'mini',
  205. placeholder: ' '
  206. },
  207. }
  208. },
  209. {
  210. width: '140px',
  211. title: '物料编码',
  212. field: 'skuCode',
  213. component: 'by-input',
  214. compConfig: {
  215. attr: {
  216. size: 'mini',
  217. placeholder: ' '
  218. },
  219. }
  220. },
  221. {
  222. width: '140px',
  223. title: '财务编号',
  224. field: 'accountingCode',
  225. component: 'by-input',
  226. compConfig: {
  227. attr: {
  228. size: 'mini',
  229. placeholder: ' '
  230. },
  231. }
  232. },
  233. {
  234. width: '90px',
  235. title: '价格',
  236. field: 'price',
  237. component: 'by-input',
  238. compConfig: {
  239. attr: {
  240. size: 'mini',
  241. placeholder: ' ',
  242. type: "number",
  243. defaultValue: 0
  244. },
  245. }
  246. },
  247. {
  248. width: '90px',
  249. title: '单位',
  250. field: 'unit',
  251. component: 'by-input',
  252. compConfig: {
  253. attr: {
  254. size: 'mini',
  255. placeholder: ' ',
  256. },
  257. }
  258. },
  259. {
  260. width: '90px',
  261. title: '单位编码',
  262. field: 'unitCode',
  263. component: 'by-input',
  264. compConfig: {
  265. attr: {
  266. size: 'mini',
  267. placeholder: ' ',
  268. },
  269. }
  270. },
  271. {
  272. width: '90px',
  273. title: '库存',
  274. field: 'stock',
  275. slot: true,
  276. },
  277. {
  278. width: '110px',
  279. title: '保质期(天)',
  280. field: 'shelfLife',
  281. component: 'by-input',
  282. compConfig: {
  283. attr: {
  284. size: 'mini',
  285. placeholder: ' ',
  286. type: "integer",
  287. },
  288. }
  289. },
  290. {
  291. width: '90px',
  292. title: '重量/g',
  293. field: 'weight',
  294. component: 'by-input',
  295. compConfig: {
  296. attr: {
  297. size: 'mini',
  298. placeholder: ' ',
  299. type: "number",
  300. },
  301. }
  302. },
  303. {
  304. width: '90px',
  305. title: '长/cm',
  306. field: 'length',
  307. component: 'by-input',
  308. compConfig: {
  309. attr: {
  310. size: 'mini',
  311. placeholder: ' ',
  312. type: "number",
  313. },
  314. }
  315. },
  316. {
  317. width: '90px',
  318. title: '宽/cm',
  319. field: 'width',
  320. component: 'by-input',
  321. compConfig: {
  322. attr: {
  323. size: 'mini',
  324. placeholder: ' ',
  325. type: "number",
  326. },
  327. }
  328. },
  329. {
  330. width: '90px',
  331. title: '高/cm',
  332. field: 'height',
  333. component: 'by-input',
  334. compConfig: {
  335. attr: {
  336. size: 'mini',
  337. placeholder: ' ',
  338. type: "number",
  339. },
  340. }
  341. },
  342. {
  343. width: '90px',
  344. title: '体积/cm³',
  345. field: 'volume',
  346. },
  347. ]
  348. }
  349. tableConfig : any = {
  350. attr: {
  351. size: 'mini',
  352. align: 'left',
  353. },
  354. columns: [
  355. {
  356. width: '160px',
  357. title: '标题',
  358. field: 'skuTitle',
  359. component: 'by-input',
  360. compConfig: {
  361. attr: {
  362. size: 'mini',
  363. placeholder: ' '
  364. },
  365. }
  366. },
  367. {
  368. width: '120px',
  369. title: '副标题',
  370. field: 'skuSubtitle',
  371. component: 'by-input',
  372. compConfig: {
  373. attr: {
  374. size: 'mini',
  375. placeholder: ' '
  376. },
  377. }
  378. },
  379. {
  380. width: '140px',
  381. title: '物料编码',
  382. field: 'skuCode',
  383. component: 'by-input',
  384. compConfig: {
  385. attr: {
  386. size: 'mini',
  387. placeholder: ' '
  388. },
  389. }
  390. },
  391. {
  392. width: '140px',
  393. title: '财务编号',
  394. field: 'accountingCode',
  395. component: 'by-input',
  396. compConfig: {
  397. attr: {
  398. size: 'mini',
  399. placeholder: ' '
  400. },
  401. }
  402. },
  403. {
  404. width: '80px',
  405. title: '价格',
  406. field: 'price',
  407. component: 'by-input',
  408. compConfig: {
  409. attr: {
  410. size: 'mini',
  411. placeholder: ' ',
  412. type: "number",
  413. },
  414. }
  415. },
  416. {
  417. width: '80px',
  418. title: '单位',
  419. field: 'unit',
  420. component: 'by-input',
  421. compConfig: {
  422. attr: {
  423. size: 'mini',
  424. placeholder: ' ',
  425. },
  426. }
  427. },
  428. {
  429. width: '80px',
  430. title: '单位编码',
  431. field: 'unitCode',
  432. component: 'by-input',
  433. compConfig: {
  434. attr: {
  435. size: 'mini',
  436. placeholder: ' ',
  437. },
  438. }
  439. },
  440. {
  441. width: '80px',
  442. title: '库存',
  443. field: 'stock',
  444. slot: true,
  445. },
  446. {
  447. width: '100px',
  448. title: '保质期(天)',
  449. field: 'shelfLife',
  450. component: 'by-input',
  451. compConfig: {
  452. attr: {
  453. size: 'mini',
  454. placeholder: ' ',
  455. type: "number",
  456. },
  457. }
  458. },
  459. {
  460. width: '80px',
  461. title: '重量/g',
  462. field: 'weight',
  463. component: 'by-input',
  464. compConfig: {
  465. attr: {
  466. size: 'mini',
  467. placeholder: ' ',
  468. type: "number",
  469. },
  470. }
  471. },
  472. {
  473. width: '80px',
  474. title: '长/cm',
  475. field: 'length',
  476. component: 'by-input',
  477. compConfig: {
  478. attr: {
  479. size: 'mini',
  480. placeholder: ' ',
  481. type: "number",
  482. },
  483. }
  484. },
  485. {
  486. width: '80px',
  487. title: '宽/cm',
  488. field: 'width',
  489. component: 'by-input',
  490. compConfig: {
  491. attr: {
  492. size: 'mini',
  493. placeholder: ' ',
  494. type: "number",
  495. },
  496. }
  497. },
  498. {
  499. width: '80px',
  500. title: '高/cm',
  501. field: 'height',
  502. component: 'by-input',
  503. compConfig: {
  504. attr: {
  505. size: 'mini',
  506. placeholder: ' ',
  507. type: "number",
  508. },
  509. }
  510. },
  511. {
  512. width: '80px',
  513. title: '体积/cm³',
  514. field: 'volume',
  515. },
  516. {
  517. width: '80px',
  518. title: '操作',
  519. action: true,
  520. plugins: [{
  521. icon: 'el-icon-delete',
  522. name: '删除',
  523. audit: '',
  524. event: {
  525. click: (item : any) => {
  526. (this as any).doDeleteTable(item)
  527. }
  528. }
  529. }]
  530. }
  531. ]
  532. }
  533. makeupTable : any = {
  534. attr: {
  535. size: 'mini',
  536. align: 'center',
  537. },
  538. columns: [
  539. {
  540. width: '170px',
  541. title: '标题',
  542. field: 'title',
  543. },
  544. {
  545. width: '170px',
  546. title: '副标题',
  547. field: 'subtitle',
  548. },
  549. {
  550. width: '170px',
  551. title: '数量',
  552. field: 'number',
  553. component: 'by-input',
  554. compConfig: {
  555. attr: {
  556. size: 'mini',
  557. defaultValue: '1',
  558. type: 'number'
  559. },
  560. }
  561. },
  562. {
  563. width: 120,
  564. title: '操作',
  565. action: true,
  566. plugins: [{
  567. name: '删除',
  568. event: {
  569. click: (item : any) => (this as any).deleteMakeup(item)
  570. }
  571. }]
  572. }
  573. ]
  574. }
  575. formConfig = {
  576. attr: {
  577. size: 'medium',
  578. rules: {
  579. name: [{
  580. required: true, message: '请输入名称', trigger: 'blur'
  581. }],
  582. basePrice: [{
  583. required: true, message: '请输入基本售价', trigger: 'blur'
  584. }],
  585. categoryName: [{
  586. required: true, message: '请选择物料分类', trigger: 'change'
  587. }],
  588. brandId: [{
  589. required: true, message: '请选择物料品牌', trigger: 'change'
  590. }],
  591. }
  592. },
  593. columns: [
  594. [
  595. {
  596. span: 6,
  597. label: '名称',
  598. prop: 'name',
  599. component: 'by-input',
  600. compConfig: {
  601. attr: {
  602. placeholder: '请输入名称',
  603. clearable: true
  604. }
  605. }
  606. },
  607. {
  608. span: 6,
  609. label: '简称',
  610. prop: 'shortName',
  611. component: 'by-input',
  612. compConfig: {
  613. attr: {
  614. placeholder: '请输入简称',
  615. clearable: true
  616. }
  617. }
  618. },
  619. {
  620. span: 6,
  621. label: '物料编码',
  622. prop: 'materialCode',
  623. component: 'by-input',
  624. compConfig: {
  625. attr: {
  626. placeholder: '请输入物料编码',
  627. }
  628. }
  629. },
  630. {
  631. span: 6,
  632. label: '货号',
  633. prop: 'itemNumber',
  634. component: 'by-input',
  635. compConfig: {
  636. attr: {
  637. placeholder: '请输入货号',
  638. clearable: true
  639. }
  640. }
  641. },
  642. ],
  643. [
  644. {
  645. span: 6,
  646. label: '基本售价',
  647. prop: 'basePrice',
  648. component: 'by-input',
  649. compConfig: {
  650. attr: {
  651. placeholder: '请输入基本售价',
  652. type: 'number'
  653. }
  654. }
  655. },
  656. {
  657. span: 6,
  658. label: '市场价格',
  659. prop: 'markPrice',
  660. component: 'by-input',
  661. compConfig: {
  662. attr: {
  663. placeholder: '请输入市场价格',
  664. type: 'number'
  665. }
  666. }
  667. },
  668. {
  669. span: 6,
  670. label: '国际码',
  671. prop: 'nsCode',
  672. component: 'by-input',
  673. compConfig: {
  674. attr: {
  675. placeholder: '请输入国际码',
  676. clearable: true
  677. }
  678. }
  679. },
  680. ],
  681. [
  682. {
  683. span: 6,
  684. label: '物料分类',
  685. prop: 'categoryName',
  686. component: 'select-tree',
  687. compConfig: {
  688. attr: {
  689. label: 'name',
  690. clearable: true,
  691. retConfig: {
  692. categoryName: 'name',
  693. categoryId: 'id'
  694. },
  695. defaultExpandAll: true
  696. },
  697. request: {
  698. url: '/maindata/maindataMaterialCategory/treeUseList'
  699. }
  700. }
  701. },
  702. {
  703. span: 6,
  704. label: '物料品牌',
  705. prop: 'brandId',
  706. component: brandType,
  707. },
  708. {
  709. span: 6,
  710. label: '虚拟分类',
  711. prop: 'vmCategoryName',
  712. component: 'select-tree',
  713. compConfig: {
  714. attr: {
  715. label: 'name',
  716. clearable: true,
  717. retConfig: {
  718. vmCategoryName: 'name',
  719. vmCategoryId: 'id'
  720. },
  721. defaultExpandAll: true
  722. },
  723. request: {
  724. url: '/maindata/maindataMaterialVmcategory/treeUseList'
  725. }
  726. }
  727. },
  728. {
  729. labelWidth: '116px',
  730. span: 6,
  731. label: '机构商品分类',
  732. prop: 'organizationCategoryName',
  733. component: 'select-tree',
  734. compConfig: {
  735. attr: {
  736. label: 'name',
  737. clearable: true,
  738. retConfig: {
  739. organizationCategoryName: 'name',
  740. organizationCategoryId: 'id'
  741. },
  742. defaultExpandAll: true
  743. },
  744. request: {
  745. url: '/maindata/maindataMaterialOrganizationCategory/treeUseList'
  746. }
  747. }
  748. },
  749. ],
  750. [
  751. {
  752. span: 30,
  753. label: '描述',
  754. slot: true,
  755. prop: 'description',
  756. }
  757. ],
  758. [
  759. {
  760. span: 20,
  761. label: '标签',
  762. slot: true,
  763. prop: 'tags',
  764. }
  765. ],
  766. [
  767. {
  768. span: 20,
  769. label: '物料状态',
  770. slot: true,
  771. prop: 'status',
  772. }
  773. ],
  774. [
  775. {
  776. span: 20,
  777. label: '组合商品',
  778. slot: true,
  779. prop: 'ismakeup',
  780. }
  781. ],
  782. [
  783. {
  784. span: 30,
  785. label: '',
  786. slot: true,
  787. prop: 'makeupTable',
  788. }
  789. ],
  790. [
  791. {
  792. span: 20,
  793. label: '是否公布',
  794. slot: true,
  795. prop: 'issued',
  796. }
  797. ],
  798. [
  799. {
  800. span: 20,
  801. label: '商品规格',
  802. slot: true,
  803. prop: 'materialSpec',
  804. }
  805. ],
  806. [
  807. {
  808. span: 30,
  809. label: '物料属性',
  810. slot: true,
  811. prop: 'attributeName',
  812. }
  813. ],
  814. ],
  815. }
  816. config : any = {
  817. attr: {
  818. calculateH: true
  819. },
  820. search: {
  821. attr: {
  822. size: 'mini'
  823. },
  824. columns: [
  825. [
  826. {
  827. span: 6,
  828. label: '名称',
  829. prop: 'name',
  830. component: 'by-input',
  831. labelWidth: '70px',
  832. compConfig: {
  833. attr: {
  834. placeholder: '请输入名称',
  835. clearable: true
  836. }
  837. },
  838. }, {
  839. span: 6,
  840. label: '简称',
  841. prop: 'shortName',
  842. component: 'by-input',
  843. labelWidth: '70px',
  844. compConfig: {
  845. attr: {
  846. placeholder: '请输入简称',
  847. clearable: true
  848. }
  849. }
  850. },
  851. {
  852. span: 6,
  853. label: '货号',
  854. prop: 'itemNumber',
  855. component: 'by-input',
  856. labelWidth: '70px',
  857. compConfig: {
  858. attr: {
  859. placeholder: '请输入货号',
  860. clearable: true
  861. }
  862. }
  863. },
  864. ],
  865. ]
  866. },
  867. tool: {
  868. tools: {
  869. add: true,
  870. delete: true,
  871. search: true,
  872. refresh: true,
  873. },
  874. // customTools: [
  875. // {
  876. // name: '同步到财务系统', icon: 'el-icon-top', audit: [''], event: {
  877. // click: () => {
  878. // (this as any).syncSystem()
  879. // }
  880. // }
  881. // },
  882. // ]
  883. },
  884. table: {
  885. attr: {
  886. size: 'mini',
  887. align: 'left',
  888. checkbox: true,
  889. },
  890. columns: [{
  891. width: 250,
  892. title: '名称',
  893. field: 'name',
  894. isDetail: true,
  895. }, {
  896. width: 200,
  897. title: '简称',
  898. field: 'shortName'
  899. }, {
  900. width: 200,
  901. title: '货号',
  902. field: 'itemNumber'
  903. }, {
  904. width: 200,
  905. title: '国际码',
  906. field: 'nsCode'
  907. }, {
  908. width: 90,
  909. title: '基本售价',
  910. field: 'basePrice'
  911. }, {
  912. width: 90,
  913. title: '市场价格', // (市场价格统一售价)
  914. field: 'markPrice'
  915. },
  916. {
  917. width: 120,
  918. title: '操作',
  919. action: true,
  920. plugins: [{
  921. icon: 'el-icon-edit',
  922. name: '编辑',
  923. audit: '',
  924. event: {
  925. click: (item : any) => {
  926. (this as any).getDetail(item)
  927. }
  928. }
  929. }, {
  930. name: '删除',
  931. event: {
  932. click: (item : any) => (this as any).doDelete2(item)
  933. }
  934. }]
  935. }]
  936. },
  937. }
  938. mounted() {
  939. this.getAttribute()
  940. this.timer = setInterval(() => {
  941. this.getDataList()
  942. }, 500)
  943. }
  944. // 确定商品新增
  945. confirmProduct(e : any) {
  946. console.log(e);
  947. this.$nextTick(() => {
  948. let nowData = (this.$refs.makeupTable as any).getValue();
  949. let names = '';
  950. if (e.length > 0) {
  951. for (const item of e) {
  952. let t = true;
  953. for (const t_item of nowData) {
  954. if (item.id == t_item.materialSkuId) {
  955. if (!names) {
  956. names = item.skuTitle
  957. } else {
  958. names = names + ',' + item.skuTitle
  959. }
  960. t = false;
  961. break;
  962. }
  963. }
  964. if (t) {
  965. let obj : any = {};
  966. obj.title = item.skuTitle
  967. obj.subtitle = item.skuSubtitle
  968. obj.materialSkuId = item.id
  969. obj.isDeleted = 0
  970. this.makeupList.push(obj);
  971. nowData.push(obj);
  972. }
  973. };
  974. (this as any).$refs.makeupTable.setValue(nowData) // 设置表格数据
  975. if (names) {
  976. this.$alert('商品 “' + names + '”已存在!', '提示', {
  977. confirmButtonText: '确定',
  978. });
  979. }
  980. }
  981. })
  982. }
  983. //点击树获取数据
  984. onChangeTree(e : any) {
  985. this.categoryIds = e.id;
  986. let loading = this.$loading({ target: '.main-container' });
  987. api.byCategoryPage({ categoryId: e.id }, 'maindataMaterialCategory').then((res : any) => {
  988. loading.close();
  989. if (res.code === 200) {
  990. (this.$refs.moduleView as any).setTableValue(res.data.records);
  991. let page = {
  992. pageNo: res.data.current, //当前页
  993. pageSize: res.data.size, //每页条数
  994. total: res.data.total //总条数
  995. };
  996. (this.$refs.moduleView as any).setPage(page);
  997. }
  998. }).catch(() => loading.close());
  999. }
  1000. // 保存编辑/新增
  1001. doFormData() {
  1002. (this as any).$refs.form.validate().then(() => {
  1003. let query = (this as any).$refs.form.getValue();
  1004. console.log('物料信息 ==> ', query);
  1005. query.materialSpec = this.materialSpec; // 商品规格
  1006. query.attributeList = JSON.stringify(this.attributeList) // 物料属性
  1007. query.attributeId = this.attributeId // 物料属性ID
  1008. query.status = this.status; // 物料状态
  1009. query.tags = this.tagsData.join(","); // 标签
  1010. query.ismakeup = this.ismakeup; // 商品组合
  1011. query.issued = this.issued; // 是否公布
  1012. query.description = this.textarea; // 备注
  1013. let data : any = {}
  1014. // 多规格
  1015. if (query.materialSpec === 1) {
  1016. if (this.tableList.length <= 0 || this.attributeList.length <= 0) return (this as any).$message.warning('多规格商品,物料属性不能为空!');
  1017. console.log('多规格表格数据 ==> ', this.tableList);
  1018. for (let v of this.tableList) {
  1019. if (!v.price) return this.$message.warning('物料价格必填');
  1020. if (parseInt(v.price) <= 0) return this.$message.warning('物料价格不能小于1');
  1021. if (!v.unit) return this.$message.warning('物料单位必填');
  1022. if (!v.stock) return this.$message.warning('物料库存必填');
  1023. if (parseInt(v.stock) <= 0) return this.$message.warning('物料库存必须为自然数');
  1024. if (!v.shelfLife) return this.$message.warning('物料保质期必填');
  1025. if (parseInt(v.shelfLife) <= 0) return this.$message.warning('物料保质期必须为自然数');
  1026. if (!v.weight) return this.$message.warning('物料重量必填');
  1027. if (parseInt(v.weight) <= 0) return this.$message.warning('物料重量不能小于1');
  1028. if (!v.length) return this.$message.warning('物料长必填');
  1029. if (parseInt(v.length) <= 0) return this.$message.warning('物料长不能小于1');
  1030. if (!v.width) return this.$message.warning('物料宽必填');
  1031. if (parseInt(v.width) <= 0) return this.$message.warning('物料宽不能小于1');
  1032. if (!v.height) return this.$message.warning('物料高必填');
  1033. if (parseInt(v.height) <= 0) return this.$message.warning('物料高不能小于1');
  1034. };
  1035. data = { maindataMaterialReceiveParam: query, maindataMaterialSkus: this.tableList }
  1036. let newArray : any = []
  1037. let materialSpecData : any = []
  1038. let attributeLength = this.attributeList.length
  1039. this.tableList.map((v : any) => {
  1040. for (let kyes in v) {
  1041. if (kyes.indexOf('_field_name') != -1) {
  1042. let key = kyes.split('_field_name')[0]
  1043. newArray.push({ [key]: v[kyes] })
  1044. }
  1045. }
  1046. })
  1047. // console.log('newArray ==> ',newArray);
  1048. for (var i = 0; i < newArray.length; i += attributeLength) {
  1049. materialSpecData.push(newArray.slice(i, i + attributeLength));
  1050. }
  1051. // console.log('materialSpecData ==> ', materialSpecData);
  1052. data.maindataMaterialSkus.map((v : any, i : any) => {
  1053. if (materialSpecData[i]) v.materialSpec = JSON.stringify(materialSpecData[i])
  1054. })
  1055. } else { // 单规格
  1056. data = { maindataMaterialReceiveParam: query, maindataMaterialSkus: (this.$refs.singeTable as any).getValue() }
  1057. // console.log('单规格表格数据 ==> ', data.maindataMaterialSkus);
  1058. for (let v of data.maindataMaterialSkus) {
  1059. if (!v.price) return this.$message.warning('物料价格必填');
  1060. if (parseInt(v.price) <= 0) return this.$message.warning('物料价格不能小于1');
  1061. if (!v.unit) return this.$message.warning('物料单位必填');
  1062. if (!v.stock) return this.$message.warning('物料库存必填');
  1063. if (parseInt(v.stock) <= 0) return this.$message.warning('物料库存必须为自然数');
  1064. if (!v.shelfLife) return this.$message.warning('物料保质期必填');
  1065. if (parseInt(v.shelfLife) <= 0) return this.$message.warning('物料保质期必须为自然数');
  1066. if (!v.weight) return this.$message.warning('物料重量必填');
  1067. if (parseInt(v.weight) <= 0) return this.$message.warning('物料重量不能小于1');
  1068. if (!v.length) return this.$message.warning('物料长必填');
  1069. if (parseInt(v.length) <= 0) return this.$message.warning('物料长不能小于1');
  1070. if (!v.width) return this.$message.warning('物料宽必填');
  1071. if (parseInt(v.width) <= 0) return this.$message.warning('物料宽不能小于1');
  1072. if (!v.height) return this.$message.warning('物料高必填');
  1073. if (parseInt(v.height) <= 0) return this.$message.warning('物料高不能小于1');
  1074. };
  1075. data.maindataMaterialSkus[0].isDeleted = 0;
  1076. data.maindataMaterialReceiveParam.attributeList = ""
  1077. }
  1078. if (this.ismakeup === 0) {
  1079. console.log('this.makeupList ==> ', this.makeupList);
  1080. if (this.makeupList.length <= 0) return this.$message.warning('请选择组合商品');
  1081. data.maindataMaterialLinks = this.makeupList;
  1082. // 表格删除
  1083. data.maindataMaterialLinks.map((v : any, i : any) => {
  1084. if (v.isDeleted === 1 && !v.id) {
  1085. data.maindataMaterialLinks.splice(i, 1)
  1086. }
  1087. });
  1088. }
  1089. console.log('data ==> ', data);
  1090. let loading = this.$loading({ target: '.main-container' });
  1091. if (this.isEdit) { // 编辑
  1092. api.updateList(data, 'maindataMaterial').then((res : any) => {
  1093. loading.close()
  1094. if (res.code === 200) {
  1095. this.isShow = 'home';
  1096. (this as any).$refs.sideTree.request();
  1097. this.getDataList();
  1098. this.$message.success('保存成功');
  1099. }
  1100. }).catch(() => loading.close());
  1101. } else {// 新增
  1102. api.saveList(data, 'maindataMaterial').then((res : any) => {
  1103. loading.close()
  1104. if (res.code === 200) {
  1105. this.isShow = 'home';
  1106. (this as any).$refs.sideTree.request();
  1107. this.getDataList();
  1108. this.$message.success('保存成功');
  1109. }
  1110. }).catch(() => loading.close());
  1111. }
  1112. });
  1113. }
  1114. // 打开新增
  1115. onAdd() {
  1116. this.isShow = 'add'; // 展示类型
  1117. this.selectValue = '' // 物料属性名称
  1118. this.towTable = '' // 表格数据
  1119. this.textarea = '' // 描述
  1120. this.tagsData = [] // 标签
  1121. this.attributeList = [] // 属性规格
  1122. this.tableList = [] // 表格数据
  1123. this.materialSpec = 0; // 单规格
  1124. this.status = 0; // 物料状态
  1125. this.ismakeup = 1; // 商品组合
  1126. this.makeupList = [] // 组合商品列表
  1127. this.issued = 0; // 是否公布
  1128. this.isSingle = true; // 显示单表格
  1129. this.isEdit = false; // 是否编辑
  1130. (this as any).$refs.byTool.setTool({ return: true, save: true });
  1131. this.$nextTick(() => {
  1132. (this as any).$refs.form.setValue(); // 设置表单数据
  1133. (this as any).$refs.singeTable.setValue([{}]) // 设置单表格数据
  1134. });
  1135. }
  1136. // 打开编辑
  1137. getDetail(e : any) {
  1138. console.log('编辑 ==> ', e);
  1139. (this as any).$refs.byTool.setTool({ return: true, save: true, delete: true });
  1140. let loading = this.$loading({ target: '.my-container' });
  1141. api.single({ id: e.id }, 'maindataMaterial').then((v : any) => {
  1142. let data = v.data;
  1143. if (data.vmCategoryId) {
  1144. api.single({ id: data.vmCategoryId }, 'maindataMaterialVmcategory').then((res : any) => {
  1145. if (res.code === 200) {
  1146. if (res.data) data.vmCategoryName = res.data.name;
  1147. }
  1148. }).catch(() => loading.close());
  1149. }
  1150. if (data.organizationCategoryId) {
  1151. api.single({ id: data.organizationCategoryId }, 'maindataMaterialOrganizationCategory').then((res : any) => {
  1152. if (res.code === 200) {
  1153. if (res.data) data.organizationCategoryName = res.data.name;
  1154. }
  1155. }).catch(() => loading.close());
  1156. }
  1157. if (data.categoryId) {
  1158. api.single({ id: data.categoryId }, 'maindataMaterialCategory').then((res : any) => {
  1159. if (res.code === 200) data.categoryName = res.data.name;
  1160. if (data.attributeId) {
  1161. api.single({ id: data.attributeId }, 'maindataMaterialAttribute').then((p : any) => {
  1162. if (p.code === 200) {
  1163. if (p.data) this.selectValue = p.data.name
  1164. }
  1165. }).catch(() => loading.close());
  1166. }
  1167. this.intercept = data.attributeId // 拦截物料属性判断
  1168. this.isEdit = true;
  1169. this.editInfo = data;
  1170. this.isShow = 'add';
  1171. // 标签
  1172. if (data.tags) {
  1173. this.tagsData = data.tags.split(",")
  1174. } else this.tagsData = [];
  1175. this.materialSpec = data.materialSpec
  1176. this.isSingle = data.materialSpec === 0 ? true : false;
  1177. if (data.attributeList) this.attributeList = JSON.parse(data.attributeList);
  1178. other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
  1179. if (info.code === 200) {
  1180. this.status = data.status
  1181. console.log(data.ismakeup);
  1182. this.ismakeup = data.ismakeup
  1183. if (data.ismakeup === 0 && data.maindataMaterialLinks.length > 0) {
  1184. (this as any).makeupList = data.maindataMaterialLinks;
  1185. setTimeout(() => {
  1186. (this as any).$refs.makeupTable.setValue(data.maindataMaterialLinks) // 设置组合表格数据
  1187. })
  1188. }
  1189. this.issued = data.issued
  1190. if (this.isSingle) {
  1191. this.selectValue = '' // 物料属性名称
  1192. this.towTable = '' // 表格数据
  1193. this.attributeList = []; // 属性规格
  1194. this.$nextTick(() => {
  1195. (this as any).$refs.singeTable.setValue(info.data);
  1196. });
  1197. } else {
  1198. this.forFun(this.attributeList[0], 0) // 生成sku
  1199. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1200. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1201. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1202. info.data.map((v : any, i : any) => {
  1203. v = Object.assign(v, skuRuleList[i])
  1204. v.dataIndex = i
  1205. });
  1206. newColumns.map((v : any) => {
  1207. tableConfig.columns.unshift({
  1208. width: '80px',
  1209. title: v.title,
  1210. field: v.field,
  1211. })
  1212. });
  1213. this.tableList = (this as any).$lodash.cloneDeep(info.data);
  1214. // console.log('表格配置 ==> ', tableConfig);
  1215. console.log('skuRuleList ==> ', skuRuleList);
  1216. console.log('表格数据 ==> ', this.tableList);
  1217. this.setTableConfig = tableConfig;
  1218. this.$nextTick(() => {
  1219. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1220. (this as any).$refs.table.setValue(this.tableList) // 设置表格数据
  1221. });
  1222. }
  1223. }
  1224. (this as any).$refs.form.setValue(data)
  1225. loading.close()
  1226. }).catch(() => loading.close());
  1227. }).catch(() => loading.close());
  1228. }
  1229. }).catch(() => loading.close());
  1230. }
  1231. // 同步到财务系统
  1232. syncSystem() {
  1233. }
  1234. // 立即生成
  1235. generateNow() {
  1236. this.forFun(this.attributeList[0], 0) // 生成sku
  1237. let newArray : any = []
  1238. let materialSpecData : any = []
  1239. let attributeLength = this.attributeList.length
  1240. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1241. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1242. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1243. let tableList = (this as any).$refs.table.getValue();
  1244. tableList.map((v : any) => {
  1245. for (let key in v) {
  1246. if (key.indexOf('_field_name') != -1) {
  1247. delete v[key]
  1248. }
  1249. }
  1250. })
  1251. skuRuleList.map((v : any) => {
  1252. for (let kyes in v) {
  1253. if (kyes.indexOf('_field_name') != -1) {
  1254. let key = kyes.split('_field_name')[0]
  1255. newArray.push({ [key]: v[kyes] })
  1256. }
  1257. }
  1258. })
  1259. // console.log('skuRuleList ==> ', skuRuleList);
  1260. for (var i = 0; i < newArray.length; i += attributeLength) {
  1261. materialSpecData.push(newArray.slice(i, i + attributeLength));
  1262. }
  1263. // console.log('materialSpecData ==> ', materialSpecData);
  1264. skuRuleList.map((v : any, i : any) => {
  1265. v.materialSpec = JSON.stringify(materialSpecData[i]);
  1266. v.dataIndex = i;
  1267. v.isDeleted = 0;
  1268. if (tableList[i] && v.materialSpec.indexOf(tableList[i].materialSpec != -1)) {
  1269. v = Object.assign(v, tableList[i])
  1270. };
  1271. })
  1272. newColumns.map((v : any) => {
  1273. tableConfig.columns.unshift({
  1274. width: '80px',
  1275. title: v.title,
  1276. field: v.field,
  1277. })
  1278. });
  1279. console.log('旧表格数据 ==> ', tableList);
  1280. console.log('新表格数据 ==> ', skuRuleList);
  1281. this.tableList = skuRuleList;
  1282. this.setTableConfig = tableConfig;
  1283. this.$nextTick(() => {
  1284. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1285. (this as any).$refs.table.setValue(this.tableList); // 设置表格数据
  1286. });
  1287. }
  1288. // 更换物料属性数据
  1289. getSelectValue(e : any) {
  1290. if (this.intercept === e) return console.log('拦截!');
  1291. this.$confirm('确定更换物料属性吗?确定之后原表格数据会被清除', '注意', {
  1292. confirmButtonText: '确定',
  1293. cancelButtonText: '取消',
  1294. type: 'warning',
  1295. center: true
  1296. }).then(() => {
  1297. api.single({ id: e }, 'maindataMaterialAttribute').then((res : any) => {
  1298. if (res.code === 200) {
  1299. this.selectList.map((v : any) => {
  1300. if (v.id === e) {
  1301. v.id = e
  1302. this.selectValue = v.name
  1303. }
  1304. });
  1305. this.intercept = e
  1306. this.attributeList = JSON.parse(res.data.attributeValue);
  1307. this.attributeId = e
  1308. this.forFun(this.attributeList[0], 0) // 生成sku
  1309. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1310. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1311. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1312. let giveInfo = (this as any).$refs.form.getValue();
  1313. skuRuleList.map((v : any, i : any) => {
  1314. v.dataIndex = i;
  1315. v.isDeleted = 0;
  1316. v.skuTitle = giveInfo.name;
  1317. v.skuSubtitle = giveInfo.shortName;
  1318. v.price = giveInfo.basePrice
  1319. })
  1320. newColumns.map((v : any) => {
  1321. tableConfig.columns.unshift({
  1322. width: '80px',
  1323. title: v.title,
  1324. field: v.field,
  1325. })
  1326. });
  1327. console.log('表格配置 ==> ', tableConfig);
  1328. console.log('表格数据 ==> ', skuRuleList);
  1329. this.setTableConfig = tableConfig;
  1330. this.tableList = skuRuleList;
  1331. this.$nextTick(() => {
  1332. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1333. (this as any).$refs.table.setValue(skuRuleList); // 设置表格数据
  1334. });
  1335. }
  1336. })
  1337. }).catch(() => { });
  1338. }
  1339. // 切换组合商品
  1340. openMakeup() {
  1341. (this.$refs.product as any).setShow(true); // 打开sku弹窗
  1342. }
  1343. // 切换商品规格
  1344. changeSingle() {
  1345. if (this.isSingle) {
  1346. if ((this as any).$refs.singeTable) this.singeTable = (this as any).$refs.singeTable.getValue()
  1347. this.isSingle = false;
  1348. this.$nextTick(() => {
  1349. // 设置表格数据
  1350. if (this.towTable) {
  1351. if ((this as any).$refs.table) {
  1352. this.tableList = this.towTable;
  1353. (this as any).$refs.table.setConfig(this.setTableConfig); // 设置表格配置
  1354. (this as any).$refs.table.setValue(this.towTable); // 设置表格数据
  1355. }
  1356. }
  1357. });
  1358. } else {
  1359. if ((this as any).$refs.table) this.towTable = (this as any).$refs.table.getValue()
  1360. this.isSingle = true;
  1361. this.$nextTick(() => {
  1362. // 设置单表格数据
  1363. if (this.singeTable) {
  1364. console.log('单表格数据 ==> ', this.singeTable);
  1365. (this as any).$refs.singeTable.setValue(this.singeTable);
  1366. } else (this as any).$refs.singeTable.setValue([{}]);
  1367. });
  1368. }
  1369. }
  1370. // 添加规格
  1371. showInput(index : any) {
  1372. this.$confirm('确定添加吗!确定后将可能影响原表格数据', '注意', {
  1373. confirmButtonText: '确定',
  1374. cancelButtonText: '取消',
  1375. type: 'warning',
  1376. center: true
  1377. }).then(() => {
  1378. let inputValue = (this as any).$refs['getValue_' + index][0].getValue();
  1379. if (!inputValue) return (this as any).$message.warning('请输入内容');
  1380. if (!/^\S*$/.test(inputValue)) return (this as any).$message.warning('输入内容不能有空格');
  1381. if (this.attributeList[index].list.indexOf(inputValue) !== -1) return (this as any).$refs['getValue_' + index][0].clearValue();
  1382. if (inputValue) {
  1383. this.attributeList[index].list.push(inputValue);
  1384. }
  1385. (this as any).$refs['getValue_' + index][0].clearValue();
  1386. this.generateNow();
  1387. this.$message.success('添加成功');
  1388. }).catch(() => this.$message.info('已取消添加'));
  1389. }
  1390. // 添加sku规格
  1391. doComfirm() {
  1392. if (!this.normsValue || !this.norms) return (this as any).$message.warning('请添加完整的规格');
  1393. if (!/^\S*$/.test(this.normsValue) || !/^\S*$/.test(this.norms)) return this.$message.warning('输入内容不能有空格');
  1394. this.$confirm('确定添加吗!确定后将可能影响原表格数据', '注意', {
  1395. confirmButtonText: '确定',
  1396. cancelButtonText: '取消',
  1397. type: 'warning',
  1398. center: true
  1399. }).then(() => {
  1400. let obj : any = {
  1401. title: this.norms,
  1402. field: this.norms + '_field_name',
  1403. list: [this.normsValue]
  1404. };
  1405. this.attributeList.push(obj);
  1406. this.norms = '';
  1407. this.normsValue = '';
  1408. this.isAdd = false;
  1409. this.generateNow();
  1410. this.$message.success('添加成功');
  1411. }).catch(() => this.$message.info('已取消添加'));
  1412. }
  1413. // 监听表格数据
  1414. getInputValue(e : any) {
  1415. // console.log('监听表格 ==> ', e);
  1416. if (e.length && e.width && e.height) {
  1417. e.volume = (e.length * e.width * e.height).toFixed(2);
  1418. }
  1419. }
  1420. // 排序生成
  1421. forFun(data : any, i : number, v ?: any) {
  1422. if (data.list) {
  1423. let d : Array<any> = [];
  1424. data.list.forEach((item : any) => {
  1425. if (i == 0) { // 第一次循环
  1426. let obj : any = {}
  1427. obj[data.field] = item
  1428. d.push(obj);
  1429. } else {
  1430. v.forEach((ele : any) => {
  1431. let obj : any = {};
  1432. obj = (this as any).$lodash.clone(ele);
  1433. obj[data.field] = item
  1434. d.push(obj);
  1435. });
  1436. }
  1437. });
  1438. i++
  1439. if (this.attributeList[i]) {
  1440. this.forFun(this.attributeList[i], i, d);
  1441. }
  1442. else {
  1443. this.skuRuleList = d;
  1444. }
  1445. }
  1446. }
  1447. // 添加标签
  1448. getTagsValue() {
  1449. let value = (this as any).$refs.tagsValue.getValue().trim();
  1450. if (!value) return this.$message.warning('请输入标签值');
  1451. this.tagsData.push(value);
  1452. (this as any).$refs.tagsValue.clearValue();
  1453. }
  1454. // 删除标签
  1455. handleClose2(index : any) {
  1456. this.$confirm('确定删除吗!', '注意', {
  1457. confirmButtonText: '确定',
  1458. cancelButtonText: '取消',
  1459. type: 'warning',
  1460. center: true
  1461. }).then(() => {
  1462. this.tagsData.splice(index, 1)
  1463. this.$message.success('删除成功');
  1464. }).catch(() => this.$message.info('已取消删除'));
  1465. }
  1466. // 删除标签
  1467. handleClose(tag : any, index : any) {
  1468. this.$confirm('确定删除吗!确定后将可能影响原表格数据', '注意', {
  1469. confirmButtonText: '确定',
  1470. cancelButtonText: '取消',
  1471. type: 'warning',
  1472. center: true
  1473. }).then(() => {
  1474. this.attributeList[index].list.splice(this.attributeList[index].list.indexOf(tag), 1);
  1475. this.generateNow();
  1476. this.$message.success('删除成功');
  1477. }).catch(() => this.$message.info('已取消删除'));
  1478. }
  1479. // 删除数组
  1480. closeGroup(index : any) {
  1481. this.$confirm('确定删除吗!确定后将可能影响原表格数据', '注意', {
  1482. confirmButtonText: '确定',
  1483. cancelButtonText: '取消',
  1484. type: 'warning',
  1485. center: true
  1486. }).then(() => {
  1487. this.attributeList.splice(index, 1);
  1488. this.generateNow();
  1489. this.$message.success('删除成功');
  1490. }).catch(() => this.$message.info('已取消删除'));
  1491. }
  1492. // 删除表格数据
  1493. doDeleteTable(item : any) {
  1494. this.$confirm('确定删除吗!', '注意', {
  1495. confirmButtonText: '确定',
  1496. cancelButtonText: '取消',
  1497. type: 'warning',
  1498. center: true
  1499. }).then(() => {
  1500. console.log(this.tableList);
  1501. (this as any).tableList.map((v : any) => {
  1502. if (v.dataIndex === item.dataIndex) v.isDeleted = 1;
  1503. })
  1504. let filterList = this.tableList.filter((v : any) => v.isDeleted !== 1);
  1505. (this as any).$refs.table.setValue(filterList); // 设置表格数据
  1506. this.$message.success('删除成功');
  1507. }).catch(() => this.$message.info('已取消删除'));
  1508. }
  1509. // 获取物料属性
  1510. getAttribute() {
  1511. api.pageList({}, 'maindataMaterialAttribute').then((res : any) => {
  1512. if (res.code === 200) {
  1513. this.selectList = res.data.records
  1514. } else this.$message.error(res.msg);
  1515. })
  1516. }
  1517. // 获取列表数据
  1518. getDataList() {
  1519. if (!this.$refs.moduleView) {
  1520. if (this.timeNum > 5) {
  1521. clearInterval(this.timer)
  1522. }
  1523. this.timeNum++;
  1524. return
  1525. }
  1526. clearInterval(this.timer)
  1527. let query = (this.$refs.moduleView as any).getQuery();
  1528. if (this.categoryIds) query.categoryIds = this.categoryIds;
  1529. console.log('表单字段 ==> ', query);
  1530. this.getPageList(query)
  1531. }
  1532. getPageList(query : any) {
  1533. let loading = this.$loading({ target: '.main-container' });
  1534. api.pageList(query, 'maindataMaterial').then((res : any) => {
  1535. if (res.code === 200) {
  1536. (this.$refs.moduleView as any).setTableValue(res.data.records);
  1537. let page = {
  1538. pageNo: res.data.current, //当前页
  1539. pageSize: res.data.size, //每页条数
  1540. total: res.data.total //总条数
  1541. };
  1542. (this.$refs.moduleView as any).setPage(page);
  1543. loading.close();
  1544. } else this.$message.error(res.msg);
  1545. })
  1546. }
  1547. // 工具栏方法
  1548. clickHandle(e : any) {
  1549. if (e === 'onAdd') this.onAdd();
  1550. if (e === 'onDelete') this.doDelete();
  1551. }
  1552. // 内页工具栏方法
  1553. insideTools(e : any) {
  1554. console.log(e);
  1555. if (e === 'onReturn') this.isShow = 'home';
  1556. if (e === 'onSave') this.doFormData();
  1557. if (e === 'onDelete') this.pageDelete(this.editInfo);
  1558. }
  1559. // 组合商品删除
  1560. deleteMakeup(item : any) {
  1561. this.$confirm('确定删除吗', '注意', {
  1562. confirmButtonText: '确定',
  1563. cancelButtonText: '取消',
  1564. type: 'warning',
  1565. center: true
  1566. }).then(() => {
  1567. let data = (this.$refs.makeupTable as any).getValue();// 获取表格数据
  1568. let i = -1;
  1569. let j = -1;
  1570. for (const v of data) {
  1571. i++;
  1572. if (v.id == item.id) {
  1573. break
  1574. }
  1575. };
  1576. for (const v of this.makeupList) {
  1577. j++;
  1578. if (v.id == item.id && item.isDeleted === 0) {
  1579. break
  1580. }
  1581. };
  1582. this.makeupList[j].isDeleted = 1;
  1583. data.splice(i, 1);
  1584. (this.$refs.makeupTable as any).setValue(data);// 设置表格数据
  1585. this.$message.success('删除成功');
  1586. }).catch(() => this.$message.info('已取消删除'));
  1587. }
  1588. // 内页删除
  1589. pageDelete(item : any) {
  1590. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1591. confirmButtonText: '确定',
  1592. cancelButtonText: '取消',
  1593. type: 'warning',
  1594. center: true
  1595. }).then(() => {
  1596. other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
  1597. if (res.code === 200) {
  1598. this.$message.success('删除成功');
  1599. this.isShow = 'home';
  1600. (this as any).$refs.sideTree.request();
  1601. this.getDataList();
  1602. } else this.$message.error(res.msg);
  1603. })
  1604. }).catch(() => this.$message.info('已取消删除'));
  1605. }
  1606. // 工具栏删除
  1607. doDelete() {
  1608. let selectData = (this.$refs.moduleView as any).getSelectData()
  1609. let ids = '';
  1610. if (selectData.length > 0) {
  1611. selectData.map((v : any) => {
  1612. ids += v.id + ','
  1613. })
  1614. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  1615. ids = ids.slice(0, ids.length - 1);
  1616. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1617. confirmButtonText: '确定',
  1618. cancelButtonText: '取消',
  1619. type: 'warning',
  1620. center: true
  1621. }).then(() => {
  1622. other.deleteSpuAndSku({ ids: ids }, 'maindataMaterial').then((res : any) => {
  1623. if (res.code === 200) {
  1624. (this as any).$refs.sideTree.request();
  1625. this.getDataList();
  1626. this.$message.success('删除成功');
  1627. } else this.$message.error(res.msg);
  1628. })
  1629. }).catch(() => this.$message.info('已取消删除'));
  1630. }
  1631. // 操作删除
  1632. doDelete2(item : any) {
  1633. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1634. confirmButtonText: '确定',
  1635. cancelButtonText: '取消',
  1636. type: 'warning',
  1637. center: true
  1638. }).then(() => {
  1639. other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
  1640. if (res.code === 200) {
  1641. (this as any).$refs.sideTree.request();
  1642. this.getDataList();
  1643. this.$message.success('删除成功');
  1644. } else this.$message.error(res.msg);
  1645. })
  1646. }).catch(() => this.$message.info('已取消删除'));
  1647. }
  1648. // 刷新
  1649. onRefresh() {
  1650. (this as any).$refs.moduleView.clearSearch();
  1651. (this as any).$refs.sideTree.request();
  1652. this.categoryIds = '';
  1653. this.getDataList();
  1654. }
  1655. }
  1656. </script>
  1657. <style lang="scss" scoped>
  1658. .my-container {
  1659. width: 100%;
  1660. box-sizing: border-box;
  1661. display: flex;
  1662. padding: 16px;
  1663. .bill-left {
  1664. position: relative;
  1665. border-right: solid #EEE 1px;
  1666. padding-right: 16px;
  1667. flex-shrink: 0;
  1668. height: 740px;
  1669. .bill-tab {
  1670. width: 150px;
  1671. height: 100%;
  1672. transition: all .5s;
  1673. overflow: hidden;
  1674. }
  1675. .tab-title {
  1676. font-size: 16px;
  1677. padding-bottom: 16px;
  1678. width: 200px;
  1679. }
  1680. }
  1681. .bill-main {
  1682. width: calc(100% - 16px);
  1683. box-sizing: border-box;
  1684. margin-left: 16px;
  1685. position: relative;
  1686. height: 100%;
  1687. overflow-y: hidden;
  1688. }
  1689. .detil {
  1690. width: 100%;
  1691. .box-shadow {
  1692. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  1693. padding: 20px;
  1694. border-radius: 4px;
  1695. border: 1px solid #e6ebf5;
  1696. background-color: #fff;
  1697. overflow: hidden;
  1698. color: #303133;
  1699. -webkit-transition: .3s;
  1700. transition: .3s;
  1701. margin-top: 20px;
  1702. }
  1703. }
  1704. @media screen and (min-width: 1700px) {
  1705. .bill-main {
  1706. min-width: 1450px;
  1707. }
  1708. }
  1709. }
  1710. </style>