unimportant_school_config.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <el-container>
  3. <el-main class="el-main-padding">
  4. <el-form
  5. ref="ruleForm"
  6. :model="ruleForm"
  7. :rules="rules"
  8. label-width="200px"
  9. class="demo-ruleForm"
  10. :inline-message="true"
  11. >
  12. <el-form-item v-if="isSuperAdmin" label="学校">
  13. <el-select
  14. v-model="ruleForm.orgId"
  15. placeholder="请选择"
  16. style="width: 180px"
  17. filterable
  18. >
  19. <el-option
  20. v-for="item in rootSchoolSelect"
  21. :key="item.id"
  22. :label="item.name"
  23. :value="item.id"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="服务接口默认考试">
  28. <el-select
  29. v-model="ruleForm.THIRD_PARTY_API_DEFAULT_EXAM_ID"
  30. class="input"
  31. :remote-method="queryExams4Select"
  32. remote
  33. :loading="queryExams4ThirdPartyApiDefaultExamId"
  34. filterable
  35. placeholder="请选择"
  36. >
  37. <el-option
  38. v-for="item in examList4ThirdPartyApiDefaultExamId"
  39. :key="item.id"
  40. :label="item.name"
  41. :value="item.id"
  42. >
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button
  48. :disabled="btnSaveDiabled"
  49. type="primary"
  50. @click="submitForm('ruleForm')"
  51. >保 存
  52. </el-button>
  53. </el-form-item>
  54. </el-form>
  55. </el-main>
  56. </el-container>
  57. </template>
  58. <script>
  59. import { mapState } from "vuex";
  60. import { CORE_API } from "@/constants/constants.js";
  61. import { EXAM_WORK_API } from "@/constants/constants.js";
  62. export default {
  63. data() {
  64. return {
  65. rootOrgList: [],
  66. propertyGroupId: "",
  67. formDataChanged: false,
  68. originalRuleForm: {},
  69. ruleForm: {
  70. relatedPropertyGroupIdList: [],
  71. orgId: null,
  72. THIRD_PARTY_API_DEFAULT_EXAM_ID: null,
  73. properties: {
  74. THIRD_PARTY_API_DEFAULT_EXAM_ID: null,
  75. },
  76. },
  77. queryExams4ThirdPartyApiDefaultExamId: false,
  78. examList4ThirdPartyApiDefaultExamId: [],
  79. rules: {},
  80. };
  81. },
  82. computed: {
  83. ...mapState({ user: (state) => state.user }),
  84. btnSaveDiabled() {
  85. console.log(this.formDataChanged);
  86. return !this.formDataChanged;
  87. },
  88. isSuperAdmin() {
  89. return this.user.roleList.some((role) => role.roleCode == "SUPER_ADMIN");
  90. },
  91. rootSchoolSelect() {
  92. let rootSchools = [];
  93. for (let i = 0; i < this.rootOrgList.length; i++) {
  94. let info = {
  95. name: this.rootOrgList[i].name + "(" + this.rootOrgList[i].id + ")",
  96. id: this.rootOrgList[i].id,
  97. };
  98. rootSchools.push(info);
  99. }
  100. return rootSchools;
  101. },
  102. },
  103. watch: {
  104. "ruleForm.orgId": {
  105. handler: function () {
  106. this.initForm();
  107. },
  108. },
  109. ruleForm: {
  110. deep: true,
  111. handler: function (newForm) {
  112. if (Object.keys(this.originalRuleForm).length > 0) {
  113. this.formDataChanged = !(
  114. newForm.THIRD_PARTY_API_DEFAULT_EXAM_ID ==
  115. this.originalRuleForm.THIRD_PARTY_API_DEFAULT_EXAM_ID
  116. );
  117. } else {
  118. this.formDataChanged = false;
  119. }
  120. },
  121. },
  122. },
  123. created() {
  124. this.ruleForm.orgId = this.user.rootOrgId;
  125. this.propertyGroupId = "config4Edit2";
  126. if (this.isSuperAdmin) {
  127. this.$httpWithMsg
  128. .get(CORE_API + "/org/getRootOrgList")
  129. .then((response) => {
  130. this.rootOrgList = response.data;
  131. });
  132. }
  133. this.initForm();
  134. },
  135. methods: {
  136. queryExams4Select(name) {
  137. console.log("queryExams; name: " + name);
  138. this.queryExams4ThirdPartyApiDefaultExamId = true;
  139. this.$httpWithMsg
  140. .get(
  141. EXAM_WORK_API +
  142. "/exam/queryByNameLike?enable=true&rootOrgId=" +
  143. this.ruleForm.orgId +
  144. "&name=" +
  145. name
  146. )
  147. .then((response) => {
  148. this.queryExams4ThirdPartyApiDefaultExamId = false;
  149. this.examList4ThirdPartyApiDefaultExamId = response.data;
  150. })
  151. .catch((response) => {
  152. console.log(response);
  153. this.queryExams4ThirdPartyApiDefaultExamId = false;
  154. });
  155. },
  156. submitForm(formName) {
  157. this.$refs[formName].validate((valid) => {
  158. if (valid) {
  159. this.ruleForm.properties.THIRD_PARTY_API_DEFAULT_EXAM_ID =
  160. this.ruleForm.THIRD_PARTY_API_DEFAULT_EXAM_ID;
  161. this.$httpWithMsg
  162. .put(CORE_API + "/org/saveOrgProperties", this.ruleForm)
  163. .then(
  164. () => {
  165. this.$notify({
  166. message: "保存成功",
  167. type: "success",
  168. });
  169. this.originalRuleForm = Object.assign({}, this.ruleForm);
  170. this.formDataChanged = false;
  171. },
  172. () => {}
  173. );
  174. } else {
  175. return false;
  176. }
  177. });
  178. },
  179. initForm() {
  180. this.ruleForm.relatedPropertyGroupIdList = ["studentClientConfig"];
  181. var url =
  182. CORE_API +
  183. "/org/getOrgPropertiesByGroupWithoutCache/" +
  184. this.ruleForm.orgId +
  185. "/" +
  186. this.propertyGroupId;
  187. this.$httpWithMsg.get(url).then((response) => {
  188. if (response) {
  189. let examId = response.data.THIRD_PARTY_API_DEFAULT_EXAM_ID;
  190. this.ruleForm.THIRD_PARTY_API_DEFAULT_EXAM_ID == examId;
  191. this.examList4ThirdPartyApiDefaultExamId = [];
  192. if (examId != null && examId != "") {
  193. this.ruleForm.THIRD_PARTY_API_DEFAULT_EXAM_ID = parseInt(examId);
  194. this.$httpWithMsg
  195. .get(EXAM_WORK_API + "/exam/" + examId)
  196. .then((response) => {
  197. this.examList4ThirdPartyApiDefaultExamId = [
  198. { id: response.data.id, name: response.data.name },
  199. ];
  200. });
  201. }
  202. this.originalRuleForm = Object.assign({}, this.ruleForm);
  203. } else {
  204. this.$notify({
  205. message: "学校设置信息暂未初始化,请立即初始化",
  206. type: "warning",
  207. });
  208. }
  209. });
  210. },
  211. },
  212. };
  213. </script>
  214. <style scoped>
  215. .input-width {
  216. width: 638px;
  217. }
  218. </style>