index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div id="">
  3. <Search
  4. ref="search"
  5. :formList="formList"
  6. :formData="formData"
  7. @onSubmit="search"
  8. ></Search>
  9. <div style="text-align: right; margin-bottom: 10px">
  10. <el-button :size="$store.state.defaultSize" @click="delPL" type="primary"
  11. >批量删除</el-button
  12. >
  13. <el-button :size="$store.state.defaultSize" @click="add" type="primary"
  14. >新增</el-button
  15. >
  16. </div>
  17. <Table
  18. ref="table"
  19. :tableData="tableData"
  20. :tableList="tableList"
  21. :rowKey="'NewPositionId'"
  22. :check="true"
  23. @selectionChange="selectionChange"
  24. @changeSort="changeSort"
  25. >
  26. <template #right="scope"
  27. ><el-button
  28. v-if="scope.row.status === 1"
  29. @click="del(scope.row, 0)"
  30. type="text"
  31. size="small"
  32. >停用</el-button
  33. >
  34. <el-button
  35. v-if="scope.row.status === 0"
  36. @click="del(scope.row, 1)"
  37. type="text"
  38. size="small"
  39. >启用</el-button
  40. >
  41. <el-button @click="del(scope.row, -1)" type="text" size="small"
  42. >删除</el-button
  43. >
  44. </template>
  45. </Table>
  46. <Pagination
  47. :pageindex="formData.pageindex"
  48. :pagesize="formData.pagesize"
  49. :total="total"
  50. @handleSizeChange="handleSizeChange"
  51. @handleCurrentChange="handleCurrentChange"
  52. ></Pagination>
  53. <Operation ref="operation"></Operation>
  54. </div>
  55. </template>
  56. <script>
  57. import Search from "@/components/search/index.vue";
  58. import Table from "@/components/table/index.vue";
  59. import Pagination from "@/components/pagination/index.vue";
  60. import Operation from "./operation.vue";
  61. export default {
  62. components: { Search, Operation, Table, Pagination },
  63. data() {
  64. return {
  65. formList: [
  66. {
  67. label: "分类:",
  68. prop: "Seat",
  69. scope: "TypeList",
  70. },
  71. ],
  72. formData: { pageindex: 1, pagesize: 10 },
  73. tableData: [],
  74. tableList: [
  75. {
  76. label: "编号",
  77. prop: "NewPositionId",
  78. },
  79. {
  80. label: "标题",
  81. prop: "Title",
  82. },
  83. {
  84. label: "类型",
  85. prop: "SeatName",
  86. },
  87. {
  88. label: "排序",
  89. prop: "SortNumber",
  90. scope: "input",
  91. width: "90",
  92. },
  93. {
  94. label: "状态",
  95. prop: "Status",
  96. scope: "options",
  97. options: [
  98. { label: "停用", value: 0 },
  99. { label: "正常", value: 1 },
  100. ],
  101. },
  102. ],
  103. total: 0,
  104. routerTableData: [],
  105. checkbox: [], //当前选中
  106. };
  107. },
  108. created() {
  109. this.$api.XfSysBussinessGetMenuList().then((res) => {
  110. this.routerTableData = res.Data || [];
  111. });
  112. this.search();
  113. },
  114. methods: {
  115. changeSort(e, item) {
  116. this.$api
  117. .XfSysBussinessUpdateSortNumber({
  118. List: [
  119. { NewPositionId: item.NewPositionId, SortNumber: parseInt(e) },
  120. ],
  121. })
  122. .then((res) => {
  123. this.search();
  124. this.$message.success("排序成功");
  125. });
  126. },
  127. selectionChange(e) {
  128. this.checkbox = e;
  129. },
  130. search(e) {
  131. if (e === "init") {
  132. this.formData = { pageindex: 1, pagesize: 10 };
  133. this.clearCheck();
  134. }
  135. this.$api.XfSysBussinessGetNewPositionList(this.formData).then((res) => {
  136. this.tableData = res.Data.List || [];
  137. this.total = res.Data.TotalCount;
  138. });
  139. },
  140. add() {
  141. this.$refs.operation.showInit();
  142. },
  143. clearCheck() {
  144. this.checkbox = [];
  145. this.$refs.table.$refs.table.clearSelection();
  146. },
  147. delPL() {
  148. if (this.checkbox.length > 0) {
  149. this.$confirm(
  150. `此操作将永久删除${this.checkbox.length}条数据, 是否继续?`,
  151. "提示",
  152. {
  153. confirmButtonText: "确定",
  154. cancelButtonText: "取消",
  155. type: "warning",
  156. }
  157. )
  158. .then(() => {
  159. let array = this.checkbox.map((item) => {
  160. return item.NewPositionId;
  161. });
  162. this.$api
  163. .XfSysBussinessEditNewPositionStatus({
  164. idarr: array,
  165. type: -1,
  166. })
  167. .then((res) => {
  168. this.$message({
  169. type: "success",
  170. message: "删除成功!",
  171. });
  172. this.clearCheck();
  173. this.search();
  174. });
  175. })
  176. .catch(() => {
  177. this.$message({
  178. type: "info",
  179. message: "已取消删除",
  180. });
  181. });
  182. } else {
  183. this.$message.error("请勾选需要删除的数据");
  184. return;
  185. }
  186. },
  187. del(item, k) {
  188. this.$api
  189. .XfSysBussinessEditNewPositionStatus({
  190. ids: item.NewPositionId,
  191. type: k,
  192. })
  193. .then((res) => {
  194. this.$message({
  195. type: "success",
  196. message: "操作成功!",
  197. });
  198. this.clearCheck();
  199. this.search();
  200. });
  201. },
  202. handleCurrentChange(e) {
  203. this.formData.pageindex = e;
  204. this.search();
  205. },
  206. handleSizeChange(e) {
  207. this.formData.pageindex = 1;
  208. this.formData.pagesize = e;
  209. this.search();
  210. },
  211. },
  212. };
  213. </script>
  214. <style lang="scss" scoped></style>