index.vue 43 KB

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