statistics0.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <!-- -->
  2. <template>
  3. <div class="statistics0">
  4. <TabList />
  5. <div class="right">
  6. <div class="top">
  7. <el-breadcrumb separator="/">
  8. <el-breadcrumb-item to="">首页</el-breadcrumb-item>
  9. <el-breadcrumb-item to="">库房管理</el-breadcrumb-item>
  10. <el-breadcrumb-item id="mytitle">库房设置</el-breadcrumb-item>
  11. </el-breadcrumb>
  12. </div>
  13. <div class="conten">
  14. <div class="conten_left">
  15. <div class="btn">
  16. <el-button type="primary" @click="addOne" v-show="userLogo.add">新建库区</el-button>
  17. <el-button type="danger" @click="delOne" v-show="userLogo.del">删除</el-button>
  18. </div>
  19. <div class="box" v-for="(item, index) in allList" :key="item.id">
  20. <div class="title" :style="arrowsShow === index?'background-color: #f2f2f2;':''">
  21. <i
  22. :class="
  23. arrowsShow === index
  24. ? 'el-icon-arrow-up'
  25. : 'el-icon-arrow-down'
  26. "
  27. @click="arrowsShowClick(index)"
  28. ></i>
  29. <span @click="arrowsShowClick(index)">{{ item.name }}</span>
  30. <i class="el-icon-plus tiny" @click="addTow(item.id)" v-show="userLogo.add"></i>
  31. <i class="el-icon-edit tiny" @click="editOne(item)" v-show="userLogo.edit"></i>
  32. </div>
  33. <ul class="area" v-show="arrowsShow === index">
  34. <li
  35. :class="{ active: entrepotShow === ind }"
  36. @click="entrepotShowClick(ind, val)"
  37. v-for="(val, ind) in item.children"
  38. :key="val.id"
  39. >
  40. {{ val.name }} 编号:{{ val.num }}
  41. </li>
  42. </ul>
  43. </div>
  44. </div>
  45. <div class="conten_right">
  46. <div class="title" v-show="towList.name">
  47. <b>{{ towList.name }}</b>
  48. <span>仓库编号:{{ towList.num }}</span>
  49. <i class="el-icon-plus" @click="addThree" v-show="userLogo.add"></i>
  50. <i class="el-icon-edit" @click="editTow" v-show="userLogo.edit"></i>
  51. <i class="el-icon-delete" @click="delTow" v-show="userLogo.del"></i>
  52. </div>
  53. <!-- 表格 -->
  54. <div class="table" v-if="towList.name">
  55. <el-table
  56. :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
  57. :data="tableData"
  58. border
  59. style="width: 100%"
  60. >
  61. <el-table-column
  62. :resizable="false"
  63. prop="num"
  64. label="货架编号"
  65. width="200"
  66. ></el-table-column>
  67. <el-table-column
  68. :resizable="false"
  69. prop="name"
  70. label="货架名称"
  71. width="200"
  72. ></el-table-column>
  73. <el-table-column
  74. :resizable="false"
  75. prop="description"
  76. label="备注"
  77. ></el-table-column>
  78. <el-table-column label="操作" width="150" :resizable="false">
  79. <template #default='{row}'>
  80. <i class="el-icon-edit" @click="editThree(row)" v-show="userLogo.edit"></i>
  81. <i class="el-icon-delete" @click="delThree(row.id)" v-show="userLogo.del"></i>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </div>
  86. <div v-else class="mydis">请先新建仓库</div>
  87. <!-- 分页器 -->
  88. <div class="paging" v-if="0">
  89. <el-pagination
  90. background
  91. layout="prev, pager, next,sizes,jumper"
  92. :total="30"
  93. >
  94. </el-pagination>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <!-- 新建库区弹出层--第一层 -->
  100. <el-dialog title="库区名称" :visible="popupOne" @close="popupOneX()">
  101. <el-input v-model="popupOneName" placeholder="请输入库区名称"></el-input>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button @click="popupOneX">取 消</el-button>
  104. <el-button type="primary" @click="popupOneOK">确 定</el-button>
  105. </div>
  106. </el-dialog>
  107. <!-- 新建库区弹出层--第二层 -->
  108. <el-dialog title="库房信息" :visible="popupTow" @close="popupTowX()">
  109. 仓库编号:<el-input v-model="popupTowNum" placeholder="请输入仓库编号" style="width:91%;margin-bottom:20px"></el-input>
  110. 仓库名称:<el-input v-model="popupTowName" placeholder="请输入仓库名称" style="width:91%"></el-input>
  111. <div slot="footer" class="dialog-footer">
  112. <el-button @click="popupTowX">取 消</el-button>
  113. <el-button type="primary" @click="popupTowOK">确 定</el-button>
  114. </div>
  115. </el-dialog>
  116. <!-- 新建库区弹出层--第三层 -->
  117. <el-dialog title="货架信息" :visible="popupThree" @close="popupThreeX()">
  118. 货架编号:<el-input v-model="popupThreeNum" placeholder="请输入货架编号" style="width:91%;margin-bottom:20px"></el-input>
  119. 货架名称:<el-input v-model="popupThreeName" placeholder="请输入货架名称" style="width:91%;margin-bottom:20px"></el-input>
  120. <div class="row">
  121. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;备注:<el-input type="textarea" :rows="3" v-model="popupThreeTxt" placeholder="请输入备注说明" style="width:91%"></el-input>
  122. </div>
  123. <div slot="footer" class="dialog-footer">
  124. <el-button @click="popupThreeX">取 消</el-button>
  125. <el-button type="primary" @click="popupThreeOK">确 定</el-button>
  126. </div>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script>
  131. import { getTreeList, addEntrepot, remove } from '../../apis/statistics0'
  132. import TabList from '@/components/tabLeft3.vue'
  133. export default {
  134. name: 'system0',
  135. // import引入的组件需要注入到对象中才能使用
  136. components: { TabList },
  137. data () {
  138. // 这里存放数据
  139. return {
  140. userLogo: {
  141. add: true, // 新增
  142. edit: true, // 编辑
  143. del: true// 删除
  144. },
  145. myId: null,
  146. // 第一层:箭头的显示隐藏
  147. arrowsShow: 0,
  148. popupOneName: '',
  149. popupOne: false,
  150. // 第二层:库区的显示和隐藏
  151. // 添加第二层的时候临时储存的第一层父亲的id
  152. popupTowId: null,
  153. entrepotShow: 0,
  154. popupTow: false,
  155. popupTowName: '',
  156. popupTowNum: '',
  157. // 第三层:
  158. popupThree: false,
  159. popupThreeNum: '',
  160. popupThreeName: '',
  161. popupThreeTxt: '',
  162. // 第二层数据
  163. towList: {},
  164. // 总数据
  165. allList: [],
  166. // 表格数据
  167. tableData: []
  168. }
  169. },
  170. // 监听属性 类似于data概念
  171. computed: {},
  172. // 监控data中的数据变化
  173. watch: {
  174. arrowsShow (val) {
  175. // console.log(999, val)
  176. if (val !== null) {
  177. if (this.allList[val].children) {
  178. this.tableData = this.allList[val].children[0].children
  179. this.$nextTick(() => {
  180. setTimeout(() => {
  181. this.towList = this.allList[val].children[0]
  182. }, 100)
  183. })
  184. } else {
  185. this.tableData = []
  186. this.towList = {}
  187. }
  188. }
  189. },
  190. entrepotShow (val) {
  191. // console.log(666, val)
  192. this.tableData = this.allList[this.arrowsShow].children[val].children
  193. }
  194. },
  195. // 方法集合
  196. methods: {
  197. // 点击新增库区--第一层
  198. editOne (val) {
  199. this.popupOneName = val.name
  200. this.myId = val.id
  201. this.popupOne = true
  202. },
  203. delOne () {
  204. if (!this.arrowsShow) return this.$message.error('未选中库区')
  205. this.$confirm('确定删除吗?', '提示', {
  206. confirmButtonText: '确定',
  207. cancelButtonText: '取消',
  208. type: 'warning'
  209. }).then(() => {
  210. remove(this.allList[this.arrowsShow].id)
  211. this.arrowsShow = null
  212. this.$nextTick(() => {
  213. setTimeout(() => {
  214. this.getTreeList()
  215. }, 100)
  216. })
  217. this.$message({
  218. type: 'success',
  219. message: '删除成功!'
  220. })
  221. }).catch(() => {
  222. this.$message({
  223. type: 'info',
  224. message: '已取消删除'
  225. })
  226. })
  227. },
  228. addOne () {
  229. this.myId = null
  230. this.popupOne = true
  231. },
  232. popupOneX () {
  233. this.popupOne = false
  234. this.popupOneName = ''
  235. },
  236. async popupOneOK () {
  237. if (this.popupOneName.trim() === '') return this.$message.error('库区名称不能为空')
  238. if (this.popupOneName.length > 8) return this.$message.error('库区名称不能超过15个字符')
  239. await addEntrepot({
  240. level: 1,
  241. name: this.popupOneName,
  242. parentId: null,
  243. id: this.myId
  244. })
  245. this.popupOne = false
  246. this.popupOneName = ''
  247. this.getTreeList()
  248. this.myId = null
  249. this.$message.success('库区操作成功')
  250. },
  251. // 点击第二层+号
  252. delTow () {
  253. this.$confirm('确定删除吗?', '提示', {
  254. confirmButtonText: '确定',
  255. cancelButtonText: '取消',
  256. type: 'warning'
  257. }).then(() => {
  258. // console.log(666, this.allList[this.arrowsShow].children[this.entrepotShow].id)
  259. remove(this.allList[this.arrowsShow].children[this.entrepotShow].id)
  260. this.entrepotShow = 0
  261. this.arrowsShow = null
  262. this.towList.name = ''
  263. this.$nextTick(() => {
  264. setTimeout(() => {
  265. this.getTreeList()
  266. }, 100)
  267. })
  268. this.$message({
  269. type: 'success',
  270. message: '删除成功!'
  271. })
  272. }).catch(() => {
  273. this.$message({
  274. type: 'info',
  275. message: '已取消删除'
  276. })
  277. })
  278. },
  279. editTow () {
  280. // console.log(666, this.towList.name)
  281. this.popupTowName = this.towList.name
  282. this.popupTowNum = this.towList.num
  283. this.myId = this.towList.id
  284. this.popupTow = true
  285. },
  286. addTow (id) {
  287. this.myId = null
  288. this.popupTowId = id
  289. this.popupTow = true
  290. },
  291. popupTowX () {
  292. this.popupTow = false
  293. this.popupTowName = ''
  294. this.popupTowNum = ''
  295. },
  296. async popupTowOK () {
  297. if (this.popupTowNum.trim() === '') return this.$message.error('仓库编号不能为空')
  298. if (this.popupTowNum.length > 8) return this.$message.error('仓库编号不能超过15个字符')
  299. if (this.popupTowName.trim() === '') return this.$message.error('仓库名称不能为空')
  300. if (this.popupTowName.length > 8) return this.$message.error('仓库名称不能超过15个字符')
  301. await addEntrepot({
  302. level: 2,
  303. name: this.popupTowName,
  304. num: this.popupTowNum,
  305. parentId: this.popupTowId,
  306. id: this.myId
  307. })
  308. this.popupTow = false
  309. this.popupTowName = ''
  310. this.popupTowNum = ''
  311. this.getTreeList()
  312. this.myId = null
  313. this.$message.success('仓库操作成功')
  314. this.$nextTick(() => {
  315. setTimeout(() => {
  316. // console.log(999, (this.allList[this.arrowsShow].children).length - 1)
  317. // console.log(999, this.allList[this.arrowsShow].children)
  318. this.entrepotShow = (this.allList[this.arrowsShow].children).length - 1
  319. this.towList = this.allList[this.arrowsShow].children[(this.allList[this.arrowsShow].children).length - 1]
  320. // console.log(999, this.towList)
  321. }, 100)
  322. })
  323. },
  324. // 点击第三层
  325. delThree (id) {
  326. this.$confirm('确定删除吗?', '提示', {
  327. confirmButtonText: '确定',
  328. cancelButtonText: '取消',
  329. type: 'warning'
  330. }).then(() => {
  331. remove(id)
  332. // 刷新页面
  333. this.$nextTick(() => {
  334. setTimeout(() => {
  335. this.getTreeList()
  336. this.tableData = this.tableData.filter(v => v.id !== id)
  337. }, 100)
  338. })
  339. this.$message({
  340. type: 'success',
  341. message: '删除成功!'
  342. })
  343. }).catch(() => {
  344. this.$message({
  345. type: 'info',
  346. message: '已取消删除'
  347. })
  348. })
  349. },
  350. editThree (val) {
  351. this.popupThreeName = val.name
  352. this.popupThreeNum = val.num
  353. this.popupThreeTxt = val.description
  354. this.myId = val.id
  355. this.popupThree = true
  356. },
  357. addThree () {
  358. this.myId = null
  359. this.popupThree = true
  360. },
  361. popupThreeX () {
  362. this.popupThree = false
  363. this.popupThreeName = ''
  364. this.popupThreeNum = ''
  365. this.popupThreeTxt = ''
  366. },
  367. async popupThreeOK () {
  368. // console.log(this.towList.id)
  369. if (this.popupThreeNum.trim() === '') return this.$message.error('货架编号不能为空')
  370. if (this.popupThreeName.trim() === '') return this.$message.error('货架名称不能为空')
  371. await addEntrepot({
  372. level: 3,
  373. name: this.popupThreeName,
  374. num: this.popupThreeNum,
  375. parentId: this.towList.id,
  376. description: this.popupThreeTxt,
  377. id: this.myId
  378. })
  379. this.popupThree = false
  380. this.popupThreeName = ''
  381. this.popupThreeNum = ''
  382. this.popupThreeTxt = ''
  383. this.getTreeList()
  384. this.myId = null
  385. this.$message.success('货架操作成功')
  386. // 刷新页面
  387. this.$nextTick(() => {
  388. setTimeout(() => {
  389. this.tableData = this.allList[this.arrowsShow].children[this.entrepotShow].children
  390. }, 100)
  391. })
  392. },
  393. // 点击箭头
  394. arrowsShowClick (index) {
  395. if (this.arrowsShow === index) this.arrowsShow = null
  396. else {
  397. this.arrowsShow = index
  398. this.entrepotShow = 0
  399. }
  400. },
  401. // 点击第二层
  402. entrepotShowClick (ind, val) {
  403. // console.log(9999999, ind, val)
  404. this.entrepotShow = ind
  405. this.towList = val
  406. // console.log(666, val)
  407. },
  408. // 封装获取库房列表方法
  409. async getTreeList () {
  410. const res = await getTreeList()
  411. this.allList = res.data
  412. // console.log(9999, res)
  413. }
  414. },
  415. // 生命周期 - 创建完成(可以访问当前this实例)
  416. created () {},
  417. // 生命周期 - 挂载完成(可以访问DOM元素)
  418. mounted () {
  419. // 调用获取库房列表
  420. this.getTreeList()
  421. this.$nextTick(() => {
  422. setTimeout(() => {
  423. this.towList = this.allList[0].children[0]
  424. this.tableData = this.towList.children
  425. }, 100)
  426. })
  427. // 获取用户角色权限标识
  428. let temp = localStorage.getItem('daliCK')
  429. temp = JSON.parse(temp)
  430. if (temp) {
  431. const temp2 = temp.role[0]
  432. if (temp2 === 'sys_edit') {
  433. this.userLogo.del = false
  434. this.userLogo.add = false
  435. this.userLogo.edit = false
  436. } // 保管部成员
  437. if (temp2 === 'sys_look') {
  438. this.userLogo.del = false
  439. this.userLogo.add = false
  440. this.userLogo.edit = false
  441. } // 其他部门人员
  442. if (temp2 === 'sys_collect') {
  443. this.userLogo.del = false
  444. this.userLogo.add = false
  445. this.userLogo.edit = false
  446. } // 征集部主任
  447. }
  448. },
  449. beforeCreate () {}, // 生命周期 - 创建之前
  450. beforeMount () {}, // 生命周期 - 挂载之前
  451. beforeUpdate () {}, // 生命周期 - 更新之前
  452. updated () {}, // 生命周期 - 更新之后
  453. beforeDestroy () {}, // 生命周期 - 销毁之前
  454. destroyed () {}, // 生命周期 - 销毁完成
  455. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  456. }
  457. </script>
  458. <style lang='less' scoped>
  459. //@import url(); 引入公共css类
  460. .statistics0 {
  461. .row{
  462. display: flex;
  463. align-items: center;
  464. }
  465. /deep/#mytitle > span {
  466. font-weight: 800;
  467. }
  468. display: flex;
  469. .right {
  470. width: 100%;
  471. display: flex;
  472. flex-direction: column;
  473. .top {
  474. padding-left: 35px;
  475. display: flex;
  476. align-items: center;
  477. box-shadow: 1px 1px 10px 1px;
  478. margin-left: 2px;
  479. height: 40px;
  480. background-color: #fff;
  481. }
  482. }
  483. .conten {
  484. flex: 1;
  485. display: flex;
  486. background-color: #fff;
  487. margin: 20px 20px 40px;
  488. padding: 30px 60px 0;
  489. .conten_left {
  490. width: 380px;
  491. height: 650px;
  492. border: 1px solid #ccc;
  493. margin-right: 30px;
  494. .btn {
  495. display: flex;
  496. justify-content: center;
  497. align-items: center;
  498. height: 80px;
  499. }
  500. .title {
  501. span {
  502. cursor: pointer;
  503. }
  504. position: relative;
  505. display: flex;
  506. align-items: center;
  507. height: 55px;
  508. // background-color: #f2f2f2;
  509. color: black;
  510. & > i {
  511. cursor: pointer;
  512. font-size: 30px;
  513. }
  514. & > i:nth-of-type(2) {
  515. right: 35px;
  516. }
  517. .tiny {
  518. position: absolute;
  519. right: 0;
  520. top: 50%;
  521. transform: translateY(-50%);
  522. float: right;
  523. margin: 0 10px;
  524. font-size: 24px;
  525. color: #a5acb3;
  526. }
  527. }
  528. .area {
  529. color: black;
  530. li {
  531. cursor: pointer;
  532. // width: 100%;
  533. // height: 33px;
  534. // line-height: 33px;
  535. margin-left: 50px;
  536. }
  537. li:hover {
  538. color: #1890ff;
  539. }
  540. .active {
  541. color: #1890ff;
  542. }
  543. }
  544. }
  545. .conten_right {
  546. .mydis{
  547. position: absolute;
  548. left: 50%;
  549. top: 50%;
  550. transform: translate(-50%,-50%);
  551. color: black;
  552. font-size: 30px;
  553. }
  554. position: relative;
  555. .table {
  556. /deep/.el-table__body-wrapper{
  557. max-height: 524px;
  558. max-width: 1150px !important;
  559. overflow-y: auto;
  560. }
  561. i {
  562. cursor: pointer;
  563. font-size: 24px;
  564. color: black;
  565. margin-left: 15px;
  566. }
  567. }
  568. .paging {
  569. position: absolute;
  570. left: 50%;
  571. transform: translateX(-50%);
  572. bottom: 20px;
  573. }
  574. flex: 1;
  575. height: 650px;
  576. border: 1px solid #ccc;
  577. .title {
  578. height: 75px;
  579. color: black;
  580. display: flex;
  581. align-items: center;
  582. & > b {
  583. font-size: 24px;
  584. margin: 0 20px;
  585. }
  586. & > span {
  587. margin-right: 20px;
  588. }
  589. & > i {
  590. cursor: pointer;
  591. font-size: 24px;
  592. margin: 0 10px;
  593. }
  594. }
  595. }
  596. }
  597. }
  598. </style>