index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div id="costClassification">
  3. <table-list
  4. rowKey="costCatId"
  5. ref="tableList"
  6. :tableSets="tableSet"
  7. :tableData="tableData"
  8. :navText="navText"
  9. :loading="loading"
  10. @addClick="addClick"
  11. >
  12. <template slot="customize">
  13. <el-button type="warning" @click="remove"> 批量删除 </el-button>
  14. </template>
  15. <template slot="btn" slot-scope="props">
  16. <el-button type="text" @click="addClick(props.scope.row)"
  17. >修改</el-button
  18. ><el-button type="text" @click="del(props.scope.row)">删除</el-button>
  19. </template>
  20. </table-list>
  21. <pagination
  22. :total="total"
  23. :pageSize.sync="formData.pageSize"
  24. :currentPage.sync="formData.pageNum"
  25. @search="search"
  26. />
  27. <dislog
  28. :dialogVisible.sync="dialogVisible"
  29. @search="search"
  30. :activeData="activeData"
  31. ></dislog>
  32. </div>
  33. </template>
  34. <script>
  35. import dislog from "./dislog.vue";
  36. import tableList from "@/components/tableList";
  37. import pagination from "@/components/pagination";
  38. export default {
  39. name: "CostClassification",
  40. components: { tableList, pagination, dislog },
  41. data() {
  42. return {
  43. loading: false,
  44. navText: {
  45. title: "成本分类",
  46. index: 0,
  47. ch: "条",
  48. num: true,
  49. choice: true,
  50. addHide: false,
  51. custom: false,
  52. openCheckMore: true,
  53. },
  54. formData: { pageSize: 10, pageNum: 1 },
  55. tableSet: [
  56. {
  57. label: "成本分类",
  58. prop: "categoryName",
  59. hidden: true,
  60. },
  61. ],
  62. tableData: [],
  63. total: 0,
  64. dialogVisible: false,
  65. activeData: {},
  66. };
  67. },
  68. created() {
  69. this.search(2);
  70. },
  71. methods: {
  72. addClick(data) {
  73. this.activeData = data || {};
  74. this.dialogVisible = true;
  75. },
  76. search(v) {
  77. this.loading = true;
  78. if (v === 2) {
  79. this.formData = {
  80. pageSize: 10,
  81. pageNum: 1,
  82. };
  83. this.$nextTick(() => {
  84. this.$refs.tableList.clearMoreActive();
  85. });
  86. }
  87. if (v === 3) {
  88. this.$nextTick(() => {
  89. this.$refs.tableList.clearMoreActive();
  90. });
  91. }
  92. this.$api
  93. .topinstcategoryList(this.formData)
  94. .then((res) => {
  95. this.tableData = res.rows;
  96. this.total = res.total;
  97. this.navText.index = res.total;
  98. })
  99. .finally(() => {
  100. this.loading = false;
  101. });
  102. },
  103. init() {
  104. this.search(2);
  105. },
  106. del(v) {
  107. this.$confirm("确定删除此内容?", "提示", {
  108. confirmButtonText: "确定",
  109. cancelButtonText: "取消",
  110. type: "warning",
  111. })
  112. .then(() => {
  113. this.$api
  114. .edittopinstcategorydeleteBatch({ costCatIds: [v.costCatId] })
  115. .then((res) => {
  116. this.$message.success("删除成功");
  117. this.$store.commit("COSTCAT");
  118. this.search(3);
  119. });
  120. })
  121. .catch(() => {});
  122. },
  123. excelPort() {
  124. if (this.$refs.tableList.allCheckData.length === 0) {
  125. this.$message.warning("请勾选数据");
  126. return;
  127. }
  128. },
  129. remove() {
  130. if (this.$refs.tableList.allCheckData.length === 0) {
  131. this.$message.warning("请勾选数据");
  132. return;
  133. }
  134. this.$confirm("确定批量删除选中的数据吗?", "提示", {
  135. confirmButtonText: "确定",
  136. cancelButtonText: "取消",
  137. type: "warning",
  138. })
  139. .then(() => {
  140. this.$api
  141. .edittopinstcategorydeleteBatch({
  142. costCatIds: this.$refs.tableList.allCheckData.map(
  143. (i) => i.costCatId
  144. ),
  145. })
  146. .then(() => {
  147. this.$message.success("批量删除成功");
  148. this.$store.commit("COSTCAT");
  149. this.search(3);
  150. });
  151. })
  152. .catch(() => {});
  153. },
  154. },
  155. };
  156. </script>
  157. <style lang="scss" scoped></style>