statistics0.vue 17 KB

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