index.vue 34 KB

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