unimportant_school_config.vue 5.8 KB

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