index.vue 47 KB

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