index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="oing pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%; height: 30px">
  26. <el-row :gutter="10">
  27. <el-col :span="24">
  28. <el-col
  29. :span="3"
  30. style="width: 66px; float: right"
  31. >
  32. <el-button
  33. type="primary"
  34. :size="searchSize"
  35. style="float: right"
  36. @click="searchList"
  37. >
  38. 刷新
  39. </el-button>
  40. </el-col>
  41. <el-col
  42. :span="3"
  43. style="width: 66px; float: right"
  44. v-if="powers.some((item) => item == '003')"
  45. >
  46. <el-button
  47. :size="searchSize"
  48. type="success"
  49. style="float: right"
  50. @click="openModal('add', false)"
  51. >
  52. 添加
  53. </el-button>
  54. </el-col>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. </template>
  59. <template #status="{ scope }">
  60. <el-tag
  61. :size="tablebtnSize"
  62. :type="scope.row.status == '0' ? 'warning' : ''"
  63. v-text="
  64. (statusOptions.find((item) => item.id == scope.row.status) || {})
  65. .label || '--'
  66. "
  67. ></el-tag>
  68. </template>
  69. <template #operation="{ scope }">
  70. <el-tooltip
  71. v-if="powers.some((item) => item == '007')"
  72. effect="dark"
  73. content="详情"
  74. placement="top"
  75. >
  76. <i
  77. class="el-icon-view tb-icon"
  78. @click="openModal(scope.row.id, true)"
  79. ></i>
  80. </el-tooltip>
  81. <el-tooltip
  82. v-if="powers.some((item) => item == '005')"
  83. effect="dark"
  84. content="修改"
  85. placement="top"
  86. >
  87. <i
  88. class="el-icon-edit tb-icon"
  89. @click="openModal(scope.row.id, false)"
  90. ></i>
  91. </el-tooltip>
  92. <el-tooltip
  93. v-if="
  94. powers.some((item) => item == '004') && scope.row.status === '1'
  95. "
  96. effect="dark"
  97. content="禁用"
  98. placement="top"
  99. >
  100. <i
  101. class="el-icon-video-pause tb-icon"
  102. @click="changeStatus(scope.row.id, scope.row.status)"
  103. ></i>
  104. </el-tooltip>
  105. <el-tooltip
  106. v-if="
  107. powers.some((item) => item == '004') && scope.row.status === '0'
  108. "
  109. effect="dark"
  110. content="启用"
  111. placement="top"
  112. >
  113. <i
  114. class="el-icon-video-play tb-icon"
  115. @click="changeStatus(scope.row.id, scope.row.status)"
  116. ></i>
  117. </el-tooltip>
  118. </template>
  119. </ex-table>
  120. <no-auth v-else></no-auth>
  121. <!-- 弹窗 新增/修改 -->
  122. <add-edit
  123. :id="modelId"
  124. :show-model="showModel"
  125. :is-detail="isDetail"
  126. @refresh="searchList"
  127. @cancel="showModel = false"
  128. />
  129. </div>
  130. </template>
  131. <script>
  132. import addEdit from "./addEdit";
  133. // import asyncRequest from "@/apis/service/process/oing";
  134. import asyncRequest from "@/mock/service/process/oing"; //引入mock数据
  135. import statusList from "@/assets/js/statusList";
  136. import roleLevel from "@/assets/js/roleLevel";
  137. import mixinPage from "@/mixins/elPaginationHandle";
  138. import { mapGetters } from "vuex";
  139. import resToken from "@/mixins/resToken";
  140. export default {
  141. name: "role",
  142. mixins: [mixinPage, resToken],
  143. components: {
  144. addEdit,
  145. },
  146. computed: {
  147. //组件SIZE设置
  148. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  149. powers() {
  150. let tran =
  151. this.$store.getters.btnList.find((item) => item.menu_route == "oing") ||
  152. {};
  153. if (tran && tran.action && tran.action.length > 0) {
  154. return tran.action;
  155. } else {
  156. return [];
  157. }
  158. },
  159. },
  160. data() {
  161. return {
  162. statusList: statusList,
  163. roleLevel: roleLevel,
  164. loading: true,
  165. showModel: false,
  166. isDetail: false,
  167. modelId: 0,
  168. parmValue: {
  169. page: 1, // 页码
  170. size: 15, // 每页显示条数
  171. },
  172. // 状态
  173. statusOptions: [
  174. { id: 0, label: "禁用" },
  175. { id: 1, label: "启用" },
  176. ],
  177. // 角色等级
  178. authOptions: [
  179. { id: "1", label: "管理员" },
  180. { id: "2", label: "非管理员" },
  181. ],
  182. // 表格 - 数据
  183. tableData: [],
  184. // 表格 - 参数
  185. table: {
  186. stripe: true,
  187. border: true,
  188. _defaultHeader_: ["setcol"],
  189. },
  190. // 表格 - 分页
  191. pageInfo: {
  192. size: 15,
  193. curr: 1,
  194. total: 0,
  195. },
  196. // 表格 - 列参数
  197. columns: [
  198. {
  199. prop: "id",
  200. label: "待办编号",
  201. },
  202. {
  203. prop: "title",
  204. label: "流程名称",
  205. },
  206. {
  207. prop: "orderNo",
  208. label: "单据号",
  209. },
  210. {
  211. prop: "type",
  212. label: "当前节点",
  213. },
  214. {
  215. prop: "timestamp",
  216. label: "停留时间",
  217. // sortable: true,
  218. // _slot_: "status",
  219. },
  220. {
  221. prop: "author",
  222. label: "发起人",
  223. // sortable: true,
  224. },
  225. {
  226. prop: "reviewer",
  227. label: "发起人部门",
  228. // fixed: "right",
  229. // _noset_: true,
  230. // _slot_: "operation",
  231. },
  232. {
  233. prop: "addTime",
  234. label: "申请时间",
  235. },
  236. ],
  237. };
  238. },
  239. mounted() {
  240. this.searchList();
  241. },
  242. methods: {
  243. restSearch() {
  244. // 表格 - 分页
  245. this.pageInfo = {
  246. size: 15,
  247. curr: 1,
  248. total: 0,
  249. };
  250. this.parmValue = {
  251. page: 1, // 页码
  252. size: 15, // 每页显示条数
  253. };
  254. this.searchList();
  255. },
  256. // 新建/编辑/详情
  257. openModal(id, isDetail) {
  258. this.showModel = true;
  259. this.modelId = id;
  260. this.isDetail = isDetail;
  261. },
  262. /**
  263. * 启用/禁用
  264. * @param {String} id id
  265. * @param {String} status 0-禁用 1-启用
  266. */
  267. async changeStatus(id, status) {
  268. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  269. confirmButtonText: "确定",
  270. cancelButtonText: "取消",
  271. type: "warning",
  272. })
  273. .then(async () => {
  274. this.loading = true;
  275. const model = {
  276. id: id,
  277. status: status === "1" ? "0" : "1",
  278. };
  279. const res = await asyncRequest.status(model);
  280. if (res && res.code === 0) {
  281. this.loading = false;
  282. this.$notify.success({
  283. title: "状态修改成功!",
  284. message: "",
  285. });
  286. await this.searchList();
  287. } else if (res && res.code >= 100 && res.code <= 104) {
  288. await this.logout();
  289. } else {
  290. this.loading = false;
  291. this.$message.warning(res.message);
  292. }
  293. })
  294. .catch(() => {
  295. console.log("取消");
  296. });
  297. },
  298. // 刷新表格
  299. async searchList() {
  300. this.loading = true;
  301. // const res = await asyncRequest.list(this.parmValue);
  302. const res = await asyncRequest.list(this.parmValue);
  303. // console.log(...res.data.list);
  304. if (res && res.code === 0 && res.data) {
  305. this.tableData = res.data.list;
  306. console.log(this.tableData);
  307. this.pageInfo.total = Number(res.data.count);
  308. } else if (res && res.code >= 100 && res.code <= 104) {
  309. await this.logout();
  310. } else {
  311. this.tableData = [];
  312. this.pageInfo.total = 0;
  313. }
  314. this.loading = false;
  315. },
  316. },
  317. };
  318. </script>
  319. <style lang="scss" scoped>
  320. </style>