config.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. :action-list="[]"
  12. @get-list="getList"
  13. >
  14. </byTable>
  15. </div>
  16. </div>
  17. <el-dialog title="修改用户名密码" v-if="editShow" v-model="editShow" width="500" destroy-on-close>
  18. <byForm :formConfig="configDataForm" :formOption="formOption" v-model="configData.data" :rules="rulesFollow" ref="configHandle">
  19. </byForm>
  20. <template #footer>
  21. <el-button @click="editShow = false" size="large">取 消</el-button>
  22. <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
  23. </template>
  24. </el-dialog>
  25. </template>
  26. <script setup>
  27. import { computed, ref } from "vue";
  28. import byTable from "@/components/byTable/index";
  29. import byForm from "@/components/byForm/index";
  30. import moment from "moment";
  31. import { ElMessage, ElMessageBox } from "element-plus";
  32. const { proxy } = getCurrentInstance();
  33. let rulesFollow = ref({
  34. username: [{ required: true, message: "请输入用户名", trigger: "change" }],
  35. password: [{ required: true, message: "请输入密码", trigger: "change" }],
  36. });
  37. const configHandle = ref(null);
  38. let configData = reactive({
  39. data: {},
  40. });
  41. let editShow = ref(false);
  42. const formOption = reactive({
  43. inline: true,
  44. labelWidth: 100,
  45. itemWidth: 100,
  46. rules: [],
  47. });
  48. const configDataForm = computed(() => {
  49. return [
  50. {
  51. type: "input",
  52. label: "用户名",
  53. prop: "username",
  54. itemWidth: 100,
  55. },
  56. {
  57. type: "input",
  58. label: "密码",
  59. prop: "password",
  60. itemWidth: 100,
  61. },
  62. ];
  63. });
  64. const sourceList = ref({
  65. data: [],
  66. pagination: {
  67. total: 0,
  68. pageNum: 1,
  69. pageSize: 10,
  70. keyword: "",
  71. status: "",
  72. sellCorporationId: "",
  73. },
  74. });
  75. const loading = ref(false);
  76. const selectConfig = computed(() => {
  77. return [
  78. ];
  79. });
  80. const config = computed(() => {
  81. return [
  82. {
  83. attrs: {
  84. label: "小满CRM账号",
  85. prop: "username",
  86. width: 200,
  87. },
  88. },
  89. {
  90. attrs: {
  91. label: "小满CRM账号密码",
  92. prop: "password",
  93. "min-width": 220,
  94. },
  95. },
  96. {
  97. attrs: {
  98. label: "client_id",
  99. prop: "clientId",
  100. width: 160,
  101. },
  102. },
  103. {
  104. attrs: {
  105. label: "client_secret",
  106. prop: "clientSecret",
  107. width: 160,
  108. },
  109. },
  110. {
  111. attrs: {
  112. label: "access_token",
  113. prop: "accessToken",
  114. "min-width": 220,
  115. },
  116. },
  117. {
  118. attrs: {
  119. label: "token过期时间",
  120. prop: "expireTime",
  121. width: 180,
  122. },
  123. },
  124. {
  125. attrs: {
  126. label: "最后一次获取token时间",
  127. prop: "lastTokenTime",
  128. width: 180,
  129. },
  130. },
  131. {
  132. attrs: {
  133. label: "操作",
  134. width: 180,
  135. align: "center",
  136. fixed: "right",
  137. },
  138. renderHTML(row) {
  139. return [
  140. {
  141. attrs: {
  142. label: "修改",
  143. type: "primary",
  144. text: true,
  145. },
  146. el: "button",
  147. click() {
  148. editConfig(row);
  149. },
  150. },
  151. ];
  152. },
  153. },
  154. ];
  155. });
  156. const getList = async (req) => {
  157. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  158. loading.value = true;
  159. proxy.post("/xiaomanConfig/page", sourceList.value.pagination).then((res) => {
  160. res.rows.forEach((x) => {
  161. x.addTagShow = false;
  162. if (x.tag) {
  163. x.tags = x.tag.split(",");
  164. } else {
  165. x.tags = [];
  166. }
  167. });
  168. sourceList.value.data = res.rows;
  169. sourceList.value.pagination.total = res.total;
  170. setTimeout(() => {
  171. loading.value = false;
  172. }, 200);
  173. });
  174. };
  175. const editConfig = (item) => {
  176. configData.data = {
  177. id: item.id,
  178. username: item.username,
  179. password: '',
  180. };
  181. editShow.value = true;
  182. };
  183. const submitForm = () => {
  184. configHandle.value.handleSubmit(() => {
  185. proxy
  186. .post("/xiaomanConfig/edit", configData.data)
  187. .then(
  188. () => {
  189. ElMessage({
  190. message: "保存成功",
  191. type: "success",
  192. });
  193. editShow.value = false;
  194. getList();
  195. },
  196. (err) => {
  197. console.log(err);
  198. }
  199. );
  200. });
  201. };
  202. getList();
  203. </script>
  204. <style lang="scss" scoped>
  205. .tenant {
  206. padding: 20px;
  207. }
  208. ::v-deep(.el-input-number .el-input__inner) {
  209. text-align: left;
  210. }
  211. .baseRow {
  212. min-height: 24px;
  213. border-top: 1px solid black;
  214. border-left: 1px solid black;
  215. }
  216. .contentRow {
  217. border-right: 1px solid black;
  218. line-height: 24px;
  219. padding-left: 4px;
  220. }
  221. </style>