index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="pageIndexClass">
  3. <div>
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
  5. :selectConfig="selectConfig" :action-list="[
  6. {
  7. text: '添加AppSecret',
  8. action: () => openModal('add'),
  9. disabled: false,
  10. },
  11. ]" @get-list="getList">
  12. <template #name="{ item }">
  13. <div>
  14. <span class="el-click">{{ item.name }}</span>
  15. </div>
  16. </template>
  17. </byTable>
  18. </div>
  19. <el-dialog :title="modalType == 'add' ? '添加AppSecret' : '编辑AppSecret'" v-model="dialogVisible" width="600px" destroy-on-close>
  20. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom" v-loading="submitLoading">
  21. </byForm>
  22. <template #footer>
  23. <el-button @click="dialogVisible = false" size="defualt" v-debounce>取 消</el-button>
  24. <el-button type="primary" @click="submitForm()" size="defualt" v-debounce :loading="submitLoading">
  25. 确 定
  26. </el-button>
  27. </template>
  28. </el-dialog>
  29. </div>
  30. </template>
  31. <script setup>
  32. import byTable from "@/components/byTable/index";
  33. import byForm from "@/components/byForm/index";
  34. const { proxy } = getCurrentInstance();
  35. const loading = ref(false);
  36. const submitLoading = ref(false);
  37. const sourceList = ref({
  38. data: [],
  39. pagination: {
  40. total: 3,
  41. pageNum: 1,
  42. pageSize: 10,
  43. keyword: "",
  44. },
  45. });
  46. const treeData = ref([]);
  47. const dialogVisible = ref(false);
  48. const modalType = ref("add");
  49. const selectConfig = computed(() => []);
  50. const config = computed(() => {
  51. return [
  52. {
  53. attrs: {
  54. label: "部门名称",
  55. prop: "deptName",
  56. width: 130,
  57. },
  58. },
  59. {
  60. attrs: {
  61. label: "应用名称",
  62. prop: "companyName",
  63. "min-width": 150,
  64. },
  65. },
  66. {
  67. attrs: {
  68. label: "AppKey",
  69. prop: "appKey",
  70. width: 300,
  71. },
  72. },
  73. {
  74. attrs: {
  75. label: "AppSecret",
  76. prop: "appSecret",
  77. width: 300,
  78. },
  79. },
  80. {
  81. attrs: {
  82. label: "accessToken",
  83. prop: "accessToken",
  84. width: 300,
  85. },
  86. },
  87. {
  88. attrs: {
  89. label: "refreshToken",
  90. prop: "refreshToken",
  91. width: 300,
  92. },
  93. },
  94. // {
  95. // attrs: {
  96. // label: "备注",
  97. // prop: "remark",
  98. // },
  99. // },
  100. {
  101. attrs: {
  102. label: "操作",
  103. width: "120",
  104. align: "center",
  105. fixed: "right",
  106. },
  107. renderHTML(row) {
  108. return [
  109. {
  110. attrs: {
  111. label: "修改",
  112. type: "primary",
  113. text: true,
  114. },
  115. el: "button",
  116. click() {
  117. getDtl(row);
  118. },
  119. },
  120. {
  121. attrs: {
  122. label: "删除",
  123. type: "danger",
  124. text: true,
  125. },
  126. el: "button",
  127. click() {
  128. proxy
  129. .msgConfirm()
  130. .then((res) => {
  131. proxy
  132. .post("/jushuitanConfig/delete", {
  133. id: row.id,
  134. })
  135. .then((res) => {
  136. proxy.msgTip("删除成功", 1);
  137. getList();
  138. });
  139. })
  140. .catch((err) => {});
  141. },
  142. },
  143. ];
  144. },
  145. },
  146. ];
  147. });
  148. const formData = reactive({
  149. data: {},
  150. });
  151. const formOption = reactive({
  152. inline: true,
  153. labelWidth: 110,
  154. itemWidth: 100,
  155. });
  156. const formDom = ref(null);
  157. const formConfig = computed(() => {
  158. return [
  159. {
  160. type: "treeSelect",
  161. prop: "deptId",
  162. label: "部门",
  163. data: treeData.value,
  164. propsTreeLabel: "deptName",
  165. propsTreeValue: "deptId",
  166. itemWidth: 100,
  167. },
  168. {
  169. type: "input",
  170. prop: "companyName",
  171. label: "应用名称",
  172. itemWidth: 100,
  173. disabled: false,
  174. },
  175. {
  176. type: "input",
  177. prop: "appKey",
  178. label: "AppKey",
  179. itemWidth: 100,
  180. disabled: false,
  181. },
  182. {
  183. type: "input",
  184. prop: "appSecret",
  185. label: "AppSecret",
  186. itemWidth: 100,
  187. disabled: false,
  188. },
  189. {
  190. type: "input",
  191. prop: "accessToken",
  192. label: "accessToken",
  193. itemWidth: 100,
  194. disabled: false,
  195. },
  196. {
  197. type: "input",
  198. prop: "refreshToken",
  199. label: "refreshToken",
  200. itemWidth: 100,
  201. disabled: false,
  202. },
  203. {
  204. type: "input",
  205. itemType: "textarea",
  206. prop: "remark",
  207. label: "备注",
  208. itemWidth: 100,
  209. disabled: false,
  210. },
  211. ];
  212. });
  213. const rules = ref({
  214. deptId: [{ required: true, message: "请选择部门", trigger: "change" }],
  215. companyName: [{ required: true, message: "请输入公司名称", trigger: "blur" }],
  216. appKey: [{ required: true, message: "请输入AppKey", trigger: "blur" }],
  217. appSecret: [{ required: true, message: "请输入AppSecret", trigger: "blur" }],
  218. accessToken: [{ required: true, message: "accessToken", trigger: "blur" }],
  219. refreshToken: [
  220. { required: true, message: "请输入refreshToken", trigger: "blur" },
  221. ],
  222. });
  223. const getList = async (req) => {
  224. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  225. loading.value = true;
  226. proxy
  227. .post("/jushuitanConfig/page", sourceList.value.pagination)
  228. .then((res) => {
  229. sourceList.value.data = res.rows;
  230. sourceList.value.pagination.total = res.total;
  231. setTimeout(() => {
  232. loading.value = false;
  233. }, 200);
  234. });
  235. };
  236. const openModal = () => {
  237. dialogVisible.value = true;
  238. modalType.value = "add";
  239. formData.data = {
  240. companyName: "",
  241. appKey: "",
  242. appSecret: "",
  243. remark: "",
  244. };
  245. };
  246. const submitForm = () => {
  247. formDom.value.handleSubmit((valid) => {
  248. submitLoading.value = true;
  249. proxy.post("/jushuitanConfig/" + modalType.value, formData.data).then(
  250. (res) => {
  251. proxy.msgTip("操作成功", 1);
  252. dialogVisible.value = false;
  253. submitLoading.value = false;
  254. getList();
  255. },
  256. (err) => {
  257. submitLoading.value = false;
  258. }
  259. );
  260. });
  261. };
  262. const getDtl = (row) => {
  263. modalType.value = "edit";
  264. proxy.post("/jushuitanConfig/detail", { id: row.id }).then((res) => {
  265. formData.data = res;
  266. dialogVisible.value = true;
  267. });
  268. };
  269. const arrayRecursion = (arr) => {
  270. arr.forEach((item) => {
  271. if (item.children && item.children.length > 0) {
  272. item.disabled = true;
  273. arrayRecursion(item.children);
  274. } else {
  275. item.disabled = false;
  276. }
  277. });
  278. return arr;
  279. };
  280. const getTreeData = () => {
  281. proxy
  282. .get("/tenantDept/list", {
  283. pageNum: 1,
  284. pageSize: 9999,
  285. keyword: "",
  286. tenantId: proxy.useUserStore().user.tenantId,
  287. })
  288. .then((res) => {
  289. treeData.value = proxy.handleTree(res.data, "deptId");
  290. arrayRecursion(treeData.value);
  291. });
  292. };
  293. getTreeData();
  294. getList();
  295. </script>
  296. <style lang="scss" scoped>
  297. .content {
  298. padding: 20px;
  299. }
  300. </style>