classify_list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="app-container">
  3. <div class="main-content">
  4. <div class="main-left">
  5. <el-button
  6. icon="el-icon-plus"
  7. type="primary"
  8. plain
  9. style="width: 100%"
  10. v-if="$checkBtnRole('add', $route.meta.roles)"
  11. @click="openAddGroupForm('add')"
  12. >新建分组</el-button
  13. >
  14. <div class="list">
  15. <div class="item">
  16. <strong class="title">所有分组</strong>
  17. </div>
  18. <div
  19. class="item"
  20. :class="activeGroup === v.productCategoryId ? 'active' : ''"
  21. v-for="v in categoryList"
  22. :key="v.productCategoryId"
  23. @click="changeGroup(v.productCategoryId, v)"
  24. >
  25. <div class="title">{{ v.productCategoryName }}</div>
  26. <el-dropdown trigger="click" @command="handleCommand">
  27. <span class="el-dropdown-link">
  28. <i class="el-icon-more icon-more"></i>
  29. </span>
  30. <el-dropdown-menu slot="dropdown">
  31. <el-dropdown-item :command="['edit', v]" v-if="$checkBtnRole('edit', $route.meta.roles)"
  32. >修改名称</el-dropdown-item
  33. >
  34. <el-dropdown-item :command="['del', v]" v-if="$checkBtnRole('del', $route.meta.roles)"
  35. >删除分组</el-dropdown-item
  36. >
  37. </el-dropdown-menu>
  38. </el-dropdown>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="main-right">
  43. <!-- 筛选条件 -->
  44. <div>
  45. <Collapse :is-collapse="isCollapse" :screen-form="searchForm">
  46. <template #right_btn>
  47. <el-button size="mini" @click="clearFn">清空</el-button>
  48. <el-button size="mini" type="primary" @click="searchFn">搜索</el-button>
  49. </template>
  50. <template #search>
  51. <el-form ref="searchForm" :model="searchForm" label-width="70px" size="mini" label-position="left">
  52. <el-row :gutter="20">
  53. <el-col :xs="24" :sm="12" :lg="6">
  54. <el-form-item label="编码" prop="productCategoryNumber">
  55. <el-input v-model="searchForm.productCategoryNumber" placeholder="请输入"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :xs="24" :sm="12" :lg="6">
  59. <el-form-item label="名称" prop="productCategoryName">
  60. <el-input v-model="searchForm.productCategoryName" placeholder="请输入"></el-input>
  61. </el-form-item>
  62. </el-col>
  63. </el-row>
  64. </el-form>
  65. </template>
  66. </Collapse>
  67. </div>
  68. <!-- 按钮 -->
  69. <div class="btn-group clearfix">
  70. <div class="fl">
  71. <el-button v-if="$checkBtnRole('add', $route.meta.roles)" type="primary" size="mini" @click="addCategoryFn"
  72. >添加类别</el-button
  73. >
  74. </div>
  75. </div>
  76. <div class="mymain-container">
  77. <!-- 列表 -->
  78. <div class="table">
  79. <el-table
  80. v-loading="listLoading"
  81. :data="dataList"
  82. element-loading-text="Loading"
  83. border
  84. fit
  85. highlight-current-row
  86. stripe
  87. >
  88. <el-table-column
  89. align="left"
  90. label="编码"
  91. prop="kingDeeCategoryNumber"
  92. min-width="160"
  93. show-overflow-tooltip
  94. ></el-table-column>
  95. <el-table-column
  96. align="left"
  97. label="品类"
  98. prop="kingDeeCategoryName"
  99. min-width="160"
  100. show-overflow-tooltip
  101. ></el-table-column>
  102. <el-table-column align="center" label="操作" min-width="160" show-overflow-tooltip>
  103. <template slot-scope="scope">
  104. <el-popconfirm
  105. confirm-button-text="好的"
  106. cancel-button-text="不用了"
  107. icon="el-icon-info"
  108. icon-color="red"
  109. title="内容确定删除吗?"
  110. @onConfirm="hanleDelete(scope.row.id)"
  111. >
  112. <el-button
  113. slot="reference"
  114. type="text"
  115. class="textColor el-popover-left"
  116. v-if="$checkBtnRole('del', $route.meta.roles)"
  117. >删除</el-button
  118. >
  119. </el-popconfirm>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. </div>
  124. <!-- 分页
  125. <div class="fr">
  126. <el-pagination
  127. :current-page="currentPage"
  128. :page-sizes="[10, 20, 30, 50]"
  129. :page-size="10"
  130. layout="total, sizes, prev, pager, next, jumper"
  131. :total="listTotal"
  132. >
  133. </el-pagination>
  134. </div> -->
  135. </div>
  136. </div>
  137. </div>
  138. <!-- 新增编辑分组 -->
  139. <el-dialog
  140. :title="addGroupFormType == 'add' ? '新建分组' : '编辑分组'"
  141. :visible.sync="addGroupFormVisible"
  142. :show-close="false"
  143. width="40%"
  144. :close-on-click-modal="false"
  145. >
  146. <el-form ref="addGroupForm" :model="addGroupForm" label-position="left" label-width="80px">
  147. <el-form-item label="分组名称" prop="">
  148. <el-input
  149. autocomplete="off"
  150. v-model="addGroupForm.productCategoryName"
  151. placeholder="请输入分组名称"
  152. ></el-input>
  153. </el-form-item>
  154. <el-form-item label="编码" prop="">
  155. <el-input
  156. autocomplete="off"
  157. v-model="addGroupForm.productCategoryNumber"
  158. placeholder="请输入"
  159. v-if="addGroupFormType == 'add'"
  160. ></el-input>
  161. <el-input
  162. v-else
  163. autocomplete="off"
  164. v-model="addGroupForm.productCategoryNumber"
  165. placeholder="请输入"
  166. disabled="disabled"
  167. ></el-input>
  168. </el-form-item>
  169. </el-form>
  170. <div slot="footer" class="dialog-footer">
  171. <el-button @click="cancelFn">取 消</el-button>
  172. <el-button type="primary" @click="btnOK">确 定</el-button>
  173. </div>
  174. </el-dialog>
  175. <!-- 添加类别弹窗 -->
  176. <ClassifyListSmall
  177. :dataCategory="dataCategory"
  178. :showAddSelect.sync="showAddSelect"
  179. :data="dataList"
  180. @updateList="updateListFn"
  181. ref="updateDate"
  182. />
  183. </div>
  184. </template>
  185. <script>
  186. import ClassifyListSmall from './components/classify_list-small'
  187. import {
  188. getProductCategoryList,
  189. getProductCategorySubList,
  190. getProductCategoryAdd,
  191. getProductCategoryEdit,
  192. getProductCategoryDelSub,
  193. getProductCategoryDel
  194. } from '@/api/basic_data/material'
  195. export default {
  196. data() {
  197. return {
  198. searchForm: {
  199. productCategoryNumber: '',
  200. productCategoryName: ''
  201. },
  202. addGroupFormVisible: false,
  203. activeGroup: '',
  204. isCollapse: true,
  205. dataList: null, // 列表数据
  206. listLoading: false, // 列表加载loading
  207. // currentPage: 1, // 当前页码
  208. // pageSize: 10, // 每页数量
  209. // listTotal: 0, // 列表总数
  210. categoryList: [], //品类列表
  211. addGroupForm: {
  212. productCategoryName: '',
  213. productCategoryNumber: ''
  214. },
  215. addGroupFormType: 'add',
  216. showAddSelect: false, //添加分类弹窗
  217. dataCategory: null //当前选中的品类
  218. }
  219. },
  220. components: {
  221. ClassifyListSmall
  222. },
  223. created() {
  224. this.getDataList()
  225. },
  226. methods: {
  227. //清空
  228. clearFn() {
  229. this.$refs.searchForm.resetFields()
  230. },
  231. //搜索
  232. searchFn() {
  233. this.getDataList({ ...this.searchForm })
  234. },
  235. //删除
  236. async hanleDelete(id) {
  237. console.log(this.dataCategory)
  238. let arr = [id]
  239. let res = arr.toString()
  240. await getProductCategoryDelSub({ ids: res })
  241. const res2 = await getProductCategorySubList({
  242. id: this.dataCategory.productCategoryId
  243. })
  244. this.dataList = res2.data
  245. this.$message.success('删除成功')
  246. },
  247. //更新列表
  248. async updateListFn(id) {
  249. const res = await getProductCategorySubList({ id })
  250. this.dataList = res.data
  251. },
  252. //添加类别
  253. async addCategoryFn() {
  254. await this.$refs.updateDate.getDataList()
  255. this.showAddSelect = true
  256. },
  257. //取消
  258. cancelFn() {
  259. this.addGroupForm = {
  260. productCategoryName: '',
  261. productCategoryNumber: ''
  262. }
  263. this.addGroupFormVisible = false
  264. },
  265. //确定
  266. async btnOK() {
  267. if (this.addGroupFormType == 'edit') {
  268. await getProductCategoryEdit({ ...this.addGroupForm })
  269. this.$message.success('编辑成功')
  270. } else {
  271. await getProductCategoryAdd({ ...this.addGroupForm })
  272. this.$message.success('新建成功')
  273. }
  274. this.addGroupForm = {
  275. productCategoryName: '',
  276. productCategoryNumber: ''
  277. }
  278. this.getDataList()
  279. this.addGroupFormVisible = false
  280. },
  281. //切换分组
  282. async changeGroup(id, v) {
  283. console.log(v)
  284. this.dataCategory = v
  285. this.activeGroup = id
  286. const res = await getProductCategorySubList({ id })
  287. this.dataList = res.data
  288. },
  289. //获取产品类别列表
  290. async getDataList(data) {
  291. const res = await getProductCategoryList(data)
  292. this.categoryList = res.data
  293. },
  294. //新建分组弹窗
  295. openAddGroupForm(type, item) {
  296. this.addGroupFormType = type
  297. if (type == 'edit') {
  298. this.addGroupForm.productCategoryNumber = item.productCategoryNumber
  299. this.addGroupForm.productCategoryName = item.productCategoryName
  300. this.addGroupForm.productCategoryId = item.productCategoryId
  301. }
  302. this.addGroupFormVisible = true
  303. },
  304. // 操作分组
  305. handleCommand(command) {
  306. let type = command[0],
  307. v = command[1]
  308. if (type == 'del') {
  309. this.$confirm('此操作将删除该分组, 是否继续?', '删除分组', {
  310. confirmButtonText: '确定',
  311. cancelButtonText: '取消',
  312. type: 'warning'
  313. })
  314. .then(() => {
  315. console.log(v, 111)
  316. getProductCategoryDel({ ids: v.productCategoryId }).then(res => {
  317. this.getDataList()
  318. this.$successMsg('删除成功')
  319. })
  320. })
  321. .catch(() => {})
  322. }
  323. if (type == 'edit') {
  324. //修改
  325. console.log(1111)
  326. this.openAddGroupForm('edit', v)
  327. }
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .main-content {
  334. display: flex;
  335. height: auto;
  336. .main-left {
  337. margin-right: 20px;
  338. padding: 10px;
  339. width: 210px;
  340. overflow-y: auto;
  341. // border: 1px solid #eaeaea;
  342. border-radius: 5px;
  343. .list {
  344. margin-top: 10px;
  345. .item {
  346. display: flex;
  347. padding: 10px;
  348. cursor: pointer;
  349. color: #333;
  350. &.active {
  351. color: #377cfd;
  352. font-weight: 600;
  353. background-color: #f5f7fa;
  354. }
  355. .title {
  356. flex: 1;
  357. min-width: 0;
  358. padding-right: 10px;
  359. font-size: 14px;
  360. }
  361. .icon-more {
  362. transform: rotate(90deg);
  363. }
  364. }
  365. }
  366. }
  367. .main-right {
  368. flex: 1;
  369. height: auto;
  370. ::v-deep .el-divider--horizontal {
  371. margin: 10px 0;
  372. }
  373. .btn-group {
  374. display: flex;
  375. justify-content: space-between;
  376. .left {
  377. display: flex;
  378. align-items: center;
  379. .tips {
  380. font-size: 14px;
  381. margin-left: 10px;
  382. }
  383. }
  384. }
  385. .list-container {
  386. margin-top: 20px;
  387. .box-card {
  388. ::v-deep .el-card__header {
  389. padding: 10px 10px 10px 20px;
  390. }
  391. .header {
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. }
  396. .body {
  397. .info {
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. font-size: 14px;
  402. color: #666;
  403. margin: 10px 0;
  404. }
  405. .content {
  406. max-width: 100%;
  407. height: 168px;
  408. overflow-y: hidden;
  409. background-color: #fafafa;
  410. word-break: break-all;
  411. border-radius: 2px;
  412. padding: 8px;
  413. font-size: 14px;
  414. line-height: 19px;
  415. .text {
  416. overflow: hidden;
  417. text-overflow: ellipsis;
  418. display: -webkit-box;
  419. -webkit-line-clamp: 8;
  420. -webkit-box-orient: vertical;
  421. }
  422. }
  423. .img {
  424. width: 100%;
  425. height: 168px;
  426. display: block;
  427. }
  428. .video {
  429. width: 100%;
  430. height: 168px;
  431. display: block;
  432. }
  433. .file {
  434. display: flex;
  435. justify-content: space-between;
  436. align-items: center;
  437. img {
  438. width: 40px;
  439. height: 40px;
  440. display: block;
  441. }
  442. }
  443. }
  444. }
  445. }
  446. .empty {
  447. display: flex;
  448. flex-direction: column;
  449. align-items: center;
  450. justify-content: center;
  451. padding: 20px 0;
  452. img {
  453. width: 280px;
  454. }
  455. div {
  456. font-size: 14px;
  457. color: #666;
  458. }
  459. }
  460. }
  461. }
  462. </style>