unimportant_school_config.vue 5.8 KB

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