index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. label: "仅会员可见:",
  67. prop: "IsMemberRead",
  68. scope: "IsMemberRead",
  69. options: [
  70. {
  71. label: "是",
  72. value: true,
  73. },
  74. {
  75. label: "否",
  76. value: false,
  77. },
  78. ],
  79. },
  80. {
  81. label: "分类:",
  82. prop: "Seat",
  83. scope: "TypeList",
  84. },
  85. ],
  86. formData: { pageindex: 1, pagesize: 10 },
  87. tableData: [],
  88. tableList: [
  89. {
  90. label: "标题",
  91. prop: "Title",
  92. },
  93. {
  94. label: "类型",
  95. prop: "SeatName",
  96. },
  97. {
  98. label: "排序",
  99. prop: "SortNumber",
  100. scope: "input",
  101. width: "90",
  102. },
  103. {
  104. label: "状态",
  105. prop: "Status",
  106. scope: "options",
  107. options: [
  108. { label: "停用", value: 0 },
  109. { label: "正常", value: 1 },
  110. ],
  111. },
  112. ],
  113. total: 0,
  114. routerTableData: [],
  115. checkbox: [], //当前选中
  116. };
  117. },
  118. created() {
  119. this.$api.XfSysBussinessGetMenuList().then((res) => {
  120. this.routerTableData = res.Data || [];
  121. });
  122. this.search();
  123. },
  124. methods: {
  125. changeSort(e, item) {
  126. this.$api
  127. .XfSysBussinessUpdateSortNumber({
  128. List: [
  129. { NewPositionId: item.NewPositionId, SortNumber: parseInt(e) },
  130. ],
  131. })
  132. .then((res) => {
  133. this.search();
  134. this.$message.success("排序成功");
  135. });
  136. },
  137. selectionChange(e) {
  138. this.checkbox = e;
  139. },
  140. search(e) {
  141. if (e === "search") {
  142. this.formData.pageindex = 1;
  143. }
  144. if (e === "init") {
  145. this.formData = { pageindex: 1, pagesize: 10 };
  146. this.clearCheck();
  147. }
  148. this.$api.XfSysBussinessGetNewPositionList(this.formData).then((res) => {
  149. this.tableData = res.Data.List || [];
  150. this.total = res.Data.TotalCount;
  151. });
  152. },
  153. add() {
  154. this.$refs.operation.showInit();
  155. },
  156. clearCheck() {
  157. this.checkbox = [];
  158. this.$refs.table.$refs.table.clearSelection();
  159. },
  160. delPL() {
  161. if (this.checkbox.length > 0) {
  162. this.$confirm(
  163. `此操作将永久删除${this.checkbox.length}条数据, 是否继续?`,
  164. "提示",
  165. {
  166. confirmButtonText: "确定",
  167. cancelButtonText: "取消",
  168. type: "warning",
  169. }
  170. )
  171. .then(() => {
  172. let array = this.checkbox.map((item) => {
  173. return item.NewPositionId;
  174. });
  175. this.$api
  176. .XfSysBussinessEditNewPositionStatus({
  177. idarr: array,
  178. type: -1,
  179. })
  180. .then((res) => {
  181. this.$message({
  182. type: "success",
  183. message: "删除成功!",
  184. });
  185. this.clearCheck();
  186. this.search();
  187. });
  188. })
  189. .catch(() => {
  190. this.$message({
  191. type: "info",
  192. message: "已取消删除",
  193. });
  194. });
  195. } else {
  196. this.$message.error("请勾选需要删除的数据");
  197. return;
  198. }
  199. },
  200. del(item, k) {
  201. this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
  202. confirmButtonText: "确定",
  203. cancelButtonText: "取消",
  204. type: "warning",
  205. })
  206. .then(() => {
  207. this.$api
  208. .XfSysBussinessEditNewPositionStatus({
  209. idarr: [item.NewPositionId],
  210. type: k,
  211. })
  212. .then((res) => {
  213. this.$message({
  214. type: "success",
  215. message: "操作成功!",
  216. });
  217. this.clearCheck();
  218. this.search();
  219. });
  220. })
  221. .catch(() => {
  222. this.$message({
  223. type: "info",
  224. message: "已取消删除",
  225. });
  226. });
  227. },
  228. handleCurrentChange(e) {
  229. this.formData.pageindex = e;
  230. this.search();
  231. },
  232. handleSizeChange(e) {
  233. this.formData.pageindex = 1;
  234. this.formData.pagesize = e;
  235. this.search();
  236. },
  237. },
  238. };
  239. </script>
  240. <style lang="scss" scoped></style>