busIns.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div id="busIns">
  3. <el-form label-position="right" label-width="110px" :model="listData">
  4. <el-form-item
  5. v-for="(items, indexs) in listitem"
  6. :key="indexs"
  7. :label="items.label"
  8. :prop="items.prop"
  9. >
  10. <div v-if="items.scope === 'buss'">
  11. <el-select
  12. v-model="eduType"
  13. placeholder="请选择教育类型"
  14. @change="changeEduType"
  15. >
  16. <el-option
  17. v-for="(item, index) in eduTypeOptions"
  18. :key="index"
  19. :label="item.educationName"
  20. :value="item.id"
  21. >
  22. </el-option>
  23. </el-select>
  24. <el-select
  25. v-model="courType"
  26. placeholder="请选择业务层次"
  27. @change="changecourseType"
  28. >
  29. <el-option
  30. v-for="(item, index) in newCourTypeOptions"
  31. :key="index"
  32. :label="item.projectName + '-' + item.businessName"
  33. :value="item.id"
  34. >
  35. </el-option>
  36. </el-select>
  37. <el-popover
  38. ref="popovers"
  39. placement="bottom"
  40. trigger="click"
  41. @show="showHandle"
  42. @hide="hideHandle"
  43. :disabled="courType ? false : true"
  44. >
  45. <el-checkbox-group v-model="sujectArray" class="checkboxSty">
  46. <el-checkbox
  47. v-for="(item, index) in newSujectOption"
  48. :label="item.newId"
  49. :key="index"
  50. >{{ item.subjectName }}</el-checkbox
  51. >
  52. </el-checkbox-group>
  53. <div style="display: block; text-align: center; margin-top: 10px">
  54. <el-button size="mini" type="primary" @click="submitSujectArray"
  55. >确定</el-button
  56. >
  57. </div>
  58. <el-button slot="reference" style="margin-left: 12px" @click="getMessage"
  59. >请选择科目</el-button
  60. >
  61. </el-popover>
  62. </div>
  63. <div v-else>
  64. <div :class="changeHeight ? 'ach' : 'clh'">
  65. <div
  66. v-for="(item, index) in newSujectApis"
  67. :key="index"
  68. class="listBoxStys"
  69. >
  70. {{
  71. item.educationName +
  72. " - " +
  73. item.projectName +
  74. " - " +
  75. item.businessName +
  76. " - " +
  77. item.subjectName
  78. }}
  79. <i class="el-icon-error closeIcons" @click="closeType(index)"></i>
  80. </div>
  81. </div>
  82. <el-button
  83. size="mini"
  84. v-if="newSujectApis.length > 1"
  85. @click="changeType"
  86. >{{ changeHeight ? "展开" : "关闭" }}</el-button
  87. >
  88. <!-- <span v-if="newSujectApis.length === 0">未选项目类型</span> -->
  89. </div>
  90. </el-form-item>
  91. </el-form>
  92. </div>
  93. </template>
  94. <script>
  95. export default {
  96. props: ["typeBus", "sujectApisTable", "newSujectApisTable"],
  97. data() {
  98. return {
  99. changeHeight: false,
  100. eduTypeOptions: [], //教育类型数据
  101. projectTypeOptions: [], //项目类型数据
  102. courTypeOptions: [], //业务层次数据
  103. newCourTypeOptions: [], //当前业务层次数据
  104. sujectOption: [], //科目数据
  105. newSujectOption: [], //当前科目数据数据
  106. eduType: "", //当前选中教育类型
  107. courType: "", //当前选中业务层次
  108. sujectApis: [], //当前存在的科目
  109. newSujectApis: [],
  110. sujectArray: [], //选中的科目
  111. listData: {},
  112. listitem: [
  113. {
  114. label: "适用业务层级",
  115. scope: "buss",
  116. },
  117. {
  118. label: "",
  119. scope: "activeBox",
  120. },
  121. ],
  122. };
  123. },
  124. watch: {
  125. sujectApisTable: {
  126. handler(newVal, oldVal) {
  127. this.sujectApis = newVal;
  128. },
  129. // 立即处理 进入页面就触发
  130. immediate: true,
  131. },
  132. newSujectApisTable: {
  133. handler(newVal, oldVal) {
  134. this.newSujectApis = newVal;
  135. },
  136. // 立即处理 进入页面就触发
  137. immediate: true,
  138. },
  139. },
  140. mounted() {
  141. this.getDict();
  142. },
  143. methods: {
  144. getMessage() {
  145. if (!this.courType) {
  146. this.$message.warning("请先选择业务层级");
  147. }
  148. },
  149. changeTypes() {
  150. var self = this;
  151. var arrays = [];
  152. this.sujectApis.map((item, index) => {
  153. this.courTypeOptions.map((items) => {
  154. if (items.id === item.split("-").map(Number)[0]) {
  155. var obj = {
  156. type: self.typeBus,
  157. educationTypeId: items.educationId,
  158. educationName: items.educationName,
  159. projectId: items.projectId,
  160. projectName: items.projectName,
  161. businessId: items.id,
  162. businessName: items.businessName,
  163. };
  164. self.sujectOption.map((i) => {
  165. if (
  166. i.id === item.split("-").map(Number)[1] &&
  167. i.courseArrays.indexOf(items.projectId) !== -1
  168. ) {
  169. obj.subjectName = i.subjectName;
  170. obj.subjectId = i.id;
  171. }
  172. });
  173. arrays.push(obj);
  174. }
  175. });
  176. });
  177. this.newSujectApis = arrays;
  178. },
  179. getDict() {
  180. this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
  181. this.eduTypeOptions = res.rows;
  182. });
  183. this.$api.inquireCourseProjectType({ status: 1 }).then((res) => {
  184. this.projectTypeOptions = res.rows;
  185. });
  186. this.$api.inquirebusinessList({ status: 1 }).then((res) => {
  187. this.courTypeOptions = res.rows;
  188. this.newCourTypeOptions = res.rows;
  189. });
  190. this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
  191. res.rows.map((item, index) => {
  192. var array = [];
  193. item.courseProjectTypes.map((items, indexs) => {
  194. array.push(items.id);
  195. });
  196. item.courseArrays = array;
  197. });
  198. this.sujectOption = res.rows;
  199. });
  200. },
  201. changeType() {
  202. this.changeHeight = !this.changeHeight;
  203. },
  204. changeEduType() {
  205. if (!(this.courType === undefined || this.courType === "")) {
  206. this.courType = "";
  207. }
  208. var arrays = [];
  209. this.courTypeOptions.map((item) => {
  210. if (item.educationId === this.eduType) {
  211. arrays.push(item);
  212. }
  213. });
  214. this.newCourTypeOptions = arrays;
  215. },
  216. changecourseType() {
  217. this.newCourTypeOptions.map((item, index) => {
  218. if (item.id === this.courType) {
  219. this.eduType = item.educationId;
  220. var array = [];
  221. this.sujectOption.map((items, indexs) => {
  222. if (items.courseArrays.indexOf(item.projectId) !== -1) {
  223. array.push(items);
  224. }
  225. });
  226. this.newSujectOption = array;
  227. }
  228. });
  229. var arrays = [];
  230. this.courTypeOptions.map((item) => {
  231. if (item.educationId === this.eduType) {
  232. arrays.push(item);
  233. }
  234. });
  235. this.newCourTypeOptions = arrays;
  236. this.$refs.popovers[0].doClose();
  237. this.$emit("amdis", this.courType);
  238. },
  239. submitSujectArray() {
  240. var self = this;
  241. this.sujectApis = this.sujectApis.filter((item, index) => {
  242. return item.split("-").map(Number)[0] !== Number(self.courType);
  243. });
  244. for (let i = 0; i < this.sujectArray.length; i++) {
  245. this.sujectApis.push(this.sujectArray[i]);
  246. }
  247. this.$refs.popovers[0].doClose();
  248. this.changeTypes();
  249. },
  250. hideHandle() {},
  251. showHandle() {
  252. var array = [];
  253. for (let i = 0; i < this.sujectApis.length; i++) {
  254. if (
  255. this.sujectApis[i].split("-").map(Number)[0] === Number(this.courType)
  256. ) {
  257. array.push(this.sujectApis[i]);
  258. }
  259. }
  260. this.sujectArray = array;
  261. this.newSujectOption.map((item) => {
  262. item.newId = this.courType + "-" + item.id;
  263. });
  264. },
  265. closeType(index) {
  266. this.sujectApis.splice(index, 1);
  267. this.changeTypes();
  268. },
  269. },
  270. };
  271. </script>
  272. <style lang="less" scoped>
  273. .checkboxSty{
  274. display: flex;
  275. flex-direction: column;
  276. }
  277. .listBoxStys {
  278. flex-shrink: 0;
  279. padding: 0px 10px;
  280. border-radius: 8px;
  281. border: 1px solid #eee;
  282. margin-right: 10px;
  283. margin-bottom: 6px;
  284. }
  285. .closeIcons {
  286. color: red;
  287. cursor: pointer;
  288. margin-left: 6px;
  289. }
  290. .ach {
  291. display: flex;
  292. align-items: center;
  293. overflow: hidden;
  294. }
  295. .clh {
  296. display: flex;
  297. align-items: center;
  298. flex-wrap: wrap;
  299. }
  300. </style>