authorityAppEdit.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-11-29 09:18:04
  4. * @LastEditTime: 2022-02-28 10:46:33
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 新增/编辑应用
  7. * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\addApp.vue
  8. -->
  9. <template>
  10. <div class="addApp flex-wrap">
  11. <!--新增应用-->
  12. <div class="addApp-form r24">
  13. <div class="addApp-form-title flex">
  14. <div class="manageTitle">
  15. 编辑应用
  16. <!-- <span class="isqy">
  17. <span>是否启用</span>
  18. <el-radio-group v-model="radio">
  19. <el-radio :label="1">是</el-radio>
  20. <el-radio :label="0">否</el-radio>
  21. </el-radio-group>
  22. </span> -->
  23. </div>
  24. <div class="btn">
  25. <!-- <el-button @click="deleteApp" class="r24" type="danger">删除</el-button> -->
  26. <el-button size="small" @click="editApp" type="primary">保存</el-button>
  27. </div>
  28. </div>
  29. <div class="addApp-form-content dialog-public-background">
  30. <el-form ref="form" class="form" :rules="rules" :model="form">
  31. <div class="flex">
  32. <el-form-item prop="name" label="应用名称">
  33. <el-input placeholder="请输入应用名称" maxlength="32" v-model="form.name"></el-input>
  34. </el-form-item>
  35. <el-form-item label="APPID">
  36. <el-input placeholder="请输入APPID" disabled v-model="form.id"></el-input>
  37. </el-form-item>
  38. <el-form-item label="APPSECRET">
  39. <el-input placeholder="请输入APPSECRET" disabled v-model="form.app"></el-input>
  40. </el-form-item>
  41. </div>
  42. <el-form-item class="url" prop="url" label="应用地址">
  43. <el-input placeholder="请输入应用地址" maxlength="200" v-model="form.url"></el-input>
  44. </el-form-item>
  45. <el-form-item prop="content" class="content" label="描述">
  46. <el-input type="textarea" maxlength="200" rows="3" placeholder="请输入描述" v-model="form.content"></el-input>
  47. </el-form-item>
  48. </el-form>
  49. </div>
  50. </div>
  51. <!--上传logo-->
  52. <div class="addApp-upload">
  53. <div class="flex">
  54. <div class="upload">
  55. <div class="title">上传Logo</div>
  56. <el-upload action="https://jsonplaceholder.typicode.com/posts/" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
  57. <i class="el-icon-plus"></i>
  58. </el-upload>
  59. </div>
  60. <div class="preview">
  61. <div class="title">预览</div>
  62. <div class="box"></div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import {
  70. GetAppDetails,
  71. EditApp,
  72. UpdateAppStatus,
  73. DeleteApp,
  74. } from "@/api/apiAuthority";
  75. export default {
  76. name: "Addapp",
  77. data () {
  78. return {
  79. form: {
  80. //应用表单
  81. name: "",
  82. id: "",
  83. app: "",
  84. url: "",
  85. content: "",
  86. },
  87. rules: {
  88. //表单验证
  89. name: [{ required: true, message: "请输入应用名称", trigger: "blur" }],
  90. content: [{ required: true, message: "请输入描述", trigger: "blur" }],
  91. },
  92. radio: 1,
  93. AppId: null,
  94. type: null, //参数类型
  95. dialogImageUrl: "",
  96. dialogVisible: false,
  97. };
  98. },
  99. created () {
  100. const { AuthId, Status } = this.$route.query;
  101. this.radio = Status;
  102. this.AppId = AuthId;
  103. this.getAppDetails(AuthId);
  104. },
  105. methods: {
  106. handleRemove (file, fileList) {
  107. console.log(file, fileList);
  108. },
  109. handlePictureCardPreview (file) {
  110. this.dialogImageUrl = file.url;
  111. this.dialogVisible = true;
  112. },
  113. //获取应用详情
  114. async getAppDetails (id) {
  115. try {
  116. const res = await GetAppDetails({
  117. AppId: id,
  118. });
  119. if (res.code === 0) {
  120. const { AppName, AppShowId, AppShowSecret, AppDesc, AppUrl } =
  121. res.returnData;
  122. this.form.name = AppName;
  123. this.form.id = AppShowId;
  124. this.form.app = AppShowSecret;
  125. this.form.content = AppDesc;
  126. this.form.url = AppUrl;
  127. } else {
  128. this.$message.error(res.message);
  129. }
  130. } catch (error) {
  131. console.log("出错了", error.message || error);
  132. }
  133. },
  134. //应用状态变更
  135. async handleChange (val) {
  136. try {
  137. const res = await UpdateAppStatus({
  138. AppId: this.AppId,
  139. Status: val,
  140. });
  141. if (res.code === 0) {
  142. this.$message.success(res.message);
  143. } else {
  144. this.$message.error(res.message);
  145. }
  146. } catch (error) {
  147. console.log("出错了", error.message || error);
  148. }
  149. },
  150. //应用状态变更
  151. async editApp () {
  152. try {
  153. const res = await EditApp({
  154. AppId: this.AppId,
  155. AppDesc: this.form.content,
  156. AppName: this.form.name,
  157. AppUrl: this.form.url,
  158. });
  159. if (res.code === 0) {
  160. this.$message.success(res.message);
  161. this.$store.dispatch("tagsView/delView", this.$route);
  162. this.$router.push("/authority");
  163. } else {
  164. this.$message.error(res.message);
  165. }
  166. } catch (error) {
  167. console.log("出错了", error.message || error);
  168. }
  169. },
  170. //应用删除
  171. async deleteApp () {
  172. try {
  173. const res = await DeleteApp({
  174. AppId: this.AppId,
  175. });
  176. if (res.code === 0) {
  177. this.$message.success(res.message);
  178. setTimeout(() => {
  179. this.$router.push("/authority");
  180. }, 2000);
  181. } else {
  182. this.$message.error(res.message);
  183. }
  184. } catch (error) {
  185. console.log("出错了", error.message || error);
  186. }
  187. },
  188. },
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. .addApp {
  193. padding: 24px;
  194. .addApp-form {
  195. flex: 1;
  196. background: #ffffff;
  197. border-radius: 4px;
  198. padding: 30px 68px 32px 24px;
  199. .title {
  200. font-size: 24px;
  201. font-family: Microsoft YaHei;
  202. font-weight: bold;
  203. color: #303133;
  204. .isqy {
  205. span {
  206. font-weight: 400;
  207. font-size: 14px;
  208. margin: 0 28px 0 42px;
  209. }
  210. }
  211. }
  212. .addApp-form-title {
  213. line-height: 32px;
  214. }
  215. .addApp-form-content {
  216. margin-top: 40px;
  217. ::v-deep .form {
  218. .el-form-item {
  219. display: flex;
  220. }
  221. .el-input__inner {
  222. height: 32px;
  223. line-height: 32px;
  224. }
  225. .url {
  226. margin-left: 10px;
  227. .el-form-item__content {
  228. width: calc(100% - 70px);
  229. }
  230. }
  231. .content {
  232. .el-form-item__content {
  233. flex: 1;
  234. }
  235. .el-form-item__label {
  236. margin-left: 10px;
  237. }
  238. }
  239. textarea {
  240. resize: none;
  241. }
  242. }
  243. }
  244. }
  245. .addApp-upload {
  246. width: 425px;
  247. background: #ffffff;
  248. border-radius: 4px;
  249. padding: 32px 32px 40px 32px;
  250. .title {
  251. font-size: 24px;
  252. font-family: Microsoft YaHei;
  253. font-weight: bold;
  254. color: #303133;
  255. margin-bottom: 22px;
  256. }
  257. ::v-deep .el-upload--picture-card {
  258. height: 160px;
  259. line-height: 160px;
  260. width: 160px;
  261. background: #f5f7fa;
  262. border: 1px dashed #2d67e3;
  263. border-radius: 4px;
  264. .el-icon-plus {
  265. font-size: 51px;
  266. color: #2d67e3;
  267. }
  268. }
  269. .preview {
  270. .box {
  271. width: 160px;
  272. height: 160px;
  273. background: #3b3c3d;
  274. border-radius: 4px;
  275. }
  276. }
  277. }
  278. }
  279. </style>