123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- <template>
- <div id="busIns">
- <el-form label-position="right" label-width="110px" :model="listData">
- <el-form-item
- v-for="(items, indexs) in listitem"
- :key="indexs"
- :label="items.label"
- :prop="items.prop"
- :required="true"
- >
- <div v-if="items.scope === 'buss'">
- <el-select
- v-model="eduType"
- placeholder="请选择教育类型"
- @change="changeEduType"
- >
- <el-option
- v-for="(item, index) in eduTypeOptions"
- :key="index"
- :label="item.educationName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-select
- v-model="courType"
- placeholder="请选择业务层次"
- @change="changecourseType"
- >
- <el-option
- v-for="(item, index) in newCourTypeOptions"
- :key="index"
- :label="item.projectName + '-' + item.businessName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-popover
- ref="popovers"
- placement="bottom"
- trigger="click"
- @show="showHandle"
- @hide="hideHandle"
- :disabled="courType ? false : true"
- >
- <el-checkbox
- v-model="checkAll"
- @change="handleCheckAllChange"
- :indeterminate="isIndeterminate"
- >全选</el-checkbox
- >
- <el-checkbox-group
- v-model="sujectArray"
- class="checkboxSty"
- @change="handleCheckedCitiesChange"
- >
- <el-checkbox
- v-for="(item, index) in newSujectOption"
- :label="item.newId"
- :key="index"
- >{{ item.subjectName }}</el-checkbox
- >
- </el-checkbox-group>
- <div style="display: block; text-align: center; margin-top: 10px">
- <el-button size="mini" type="primary" @click="submitSujectArray"
- >确定</el-button
- >
- </div>
- <el-button
- slot="reference"
- style="margin-left: 12px"
- @click="getMessage"
- >请选择科目</el-button
- >
- </el-popover>
- </div>
- <div v-else>
- <div :class="changeHeight ? 'ach' : 'clh'">
- <div
- v-for="(item, index) in newSujectApis"
- :key="index"
- class="listBoxStys"
- >
- {{
- item.educationName +
- " - " +
- item.projectName +
- " - " +
- item.businessName +
- " - " +
- item.subjectName
- }}
- <i class="el-icon-error closeIcons" @click="closeType(index)"></i>
- </div>
- </div>
- <el-popover
- placement="bottom-start"
- trigger="hover"
- :close-delay="50"
- >
- <ul style="margin: 0; max-width: 600px">
- <li
- class="copyDataLi"
- :class="changeSty(itemT)"
- v-for="(itemT, indexT) in localData"
- :key="indexT"
- @click="unTime(itemT)"
- >
- {{
- `${itemT.educationName}-${itemT.projectName}-${itemT.businessName}-${itemT.subjectName}`
- }}
- </li>
- </ul>
- <el-button
- v-show="localData.length"
- type="danger"
- slot="reference"
- size="mini"
- style="margin-right: 10px"
- >最近选择</el-button
- >
- </el-popover>
- <el-button
- size="mini"
- v-if="newSujectApis.length > 1"
- @click="changeType"
- >{{ changeHeight ? "展开" : "关闭" }}</el-button
- ><el-button
- size="mini"
- v-if="newSujectApis.length > 0"
- @click="sujectApis = []"
- >清空</el-button
- >
- <!-- <span v-if="newSujectApis.length === 0">未选项目类型</span> -->
- </div>
- </el-form-item>
- </el-form>
- </div>
- </template>
- <script>
- export default {
- props: ["typeBus", "sujectApisTable", "newSujectApisTable"],
- data() {
- return {
- isIndeterminate: false,
- checkAll: false,
- changeHeight: false,
- eduTypeOptions: [], //教育类型数据
- projectTypeOptions: [], //项目类型数据
- courTypeOptions: [], //业务层次数据
- newCourTypeOptions: [], //当前业务层次数据
- sujectOption: [], //科目数据
- newSujectOption: [], //当前科目数据数据
- eduType: "", //当前选中教育类型
- courType: "", //当前选中业务层次
- sujectApis: [], //当前存在的科目
- newSujectApis: [],
- sujectArray: [], //选中的科目
- listData: {},
- listitem: [
- {
- label: "适用业务层级",
- scope: "buss",
- },
- {
- label: "",
- scope: "activeBox",
- },
- ],
- };
- },
- watch: {
- sujectApis: {
- immediate: true,
- handler(newName, oldName) {
- this.changeTypes();
- },
- },
- sujectApisTable: {
- handler(newVal, oldVal) {
- this.sujectApis = newVal;
- },
- // 立即处理 进入页面就触发
- immediate: true,
- },
- newSujectApisTable: {
- handler(newVal, oldVal) {
- this.newSujectApis = newVal;
- },
- // 立即处理 进入页面就触发
- immediate: true,
- },
- newSujectApis: {
- handler(newVal, oldVal) {
- if (newVal && newVal.length > 0) {
- const finds = newVal.findIndex((item) => {
- return item.businessName === "安管三类";
- });
- this.$emit("disableType", finds);
- }else{
- this.$emit("disableType", -1);
- }
- },
- immediate: true,
- },
- },
- created() {
- this.localData = this.$methodsTools.getBusinessList();
- },
- mounted() {
- this.getDict();
- },
- methods: {
- UPDates() {
- this.localData = this.$methodsTools.getBusinessList();
- },
- unTime(val) {
- let a = `${val.businessId}-${val.subjectId}`;
- if (this.sujectApis.includes(a)) {
- this.sujectApis.splice(this.sujectApis.indexOf(a), 1);
- } else {
- this.sujectApis.push(a);
- }
- },
- changeSty(val) {
- var arr = "";
- this.sujectApis.forEach((item) => {
- let arr1 = item.split("-").map(Number);
- if (val.businessId == arr1[0] && val.subjectId == arr1[1]) {
- arr = "activeStyIcons";
- }
- });
- return arr;
- },
- handleCheckedCitiesChange() {
- let nid = this.newSujectOption.map((item) => {
- return item.newId;
- });
- this.checkAll = this.sujectArray.length === nid.length;
- this.isIndeterminate =
- this.sujectArray.length > 0 && this.sujectArray.length < nid.length;
- },
- setFunc(arr) {
- var arrays = [];
- for (let i = 0; i < arr.length; i++) {
- if (!arrays.includes(arr[i])) {
- arrays.push(arr[i]);
- }
- }
- return arrays;
- },
- handleCheckAllChange(val) {
- if (val) {
- let nid = this.newSujectOption.map((item) => {
- return item.newId;
- });
- let arrays = this.sujectArray.concat(nid);
- this.sujectArray = this.setFunc(arrays);
- this.isIndeterminate = false;
- } else {
- let nid = this.newSujectOption.map((item) => {
- return item.newId;
- });
- let newArr = [];
- this.sujectArray.forEach((item) => {
- if (!nid.includes(item)) {
- newArr.push(item);
- }
- });
- this.sujectArray = newArr;
- this.isIndeterminate = false;
- }
- },
- getMessage() {
- if (!this.courType) {
- this.$message.warning("请先选择业务层级");
- }
- },
- changeTypes() {
- var self = this;
- var arrays = [];
- this.sujectApis.map((item, index) => {
- this.courTypeOptions.map((items) => {
- if (items.id === item.split("-").map(Number)[0]) {
- var obj = {
- type: self.typeBus,
- educationTypeId: items.educationId,
- educationName: items.educationName,
- projectId: items.projectId,
- projectName: items.projectName,
- businessId: items.id,
- businessName: items.businessName,
- };
- self.sujectOption.map((i) => {
- if (
- i.id === item.split("-").map(Number)[1] &&
- i.courseArrays.indexOf(items.projectId) !== -1
- ) {
- obj.subjectName = i.subjectName;
- obj.subjectId = i.id;
- }
- });
- arrays.push(obj);
- }
- });
- });
- this.newSujectApis = arrays;
- },
- getDict() {
- this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
- this.eduTypeOptions = res.rows;
- });
- this.$api.inquireCourseProjectType({ status: 1 }).then((res) => {
- this.projectTypeOptions = res.rows;
- });
- this.$api.inquirebusinessList({ status: 1 }).then((res) => {
- this.courTypeOptions = res.rows;
- this.newCourTypeOptions = res.rows;
- });
- this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
- res.rows.map((item, index) => {
- var array = [];
- item.courseProjectTypes.map((items, indexs) => {
- array.push(items.id);
- });
- item.courseArrays = array;
- });
- this.sujectOption = res.rows;
- });
- },
- changeType() {
- this.changeHeight = !this.changeHeight;
- },
- changeEduType() {
- if (!(this.courType === undefined || this.courType === "")) {
- this.courType = "";
- }
- var arrays = [];
- this.courTypeOptions.map((item) => {
- if (item.educationId === this.eduType) {
- arrays.push(item);
- }
- });
- this.newCourTypeOptions = arrays;
- },
- changecourseType() {
- this.newCourTypeOptions.map((item, index) => {
- if (item.id === this.courType) {
- this.eduType = item.educationId;
- var array = [];
- this.sujectOption.map((items, indexs) => {
- if (items.courseArrays.indexOf(item.projectId) !== -1) {
- array.push(items);
- }
- });
- this.newSujectOption = array;
- }
- });
- var arrays = [];
- this.courTypeOptions.map((item) => {
- if (item.educationId === this.eduType) {
- arrays.push(item);
- }
- });
- this.newCourTypeOptions = arrays;
- this.$refs.popovers[0].doClose();
- this.$emit("amdis", this.courType);
- },
- submitSujectArray() {
- var self = this;
- this.sujectApis = this.sujectApis.filter((item, index) => {
- return item.split("-").map(Number)[0] !== Number(self.courType);
- });
- for (let i = 0; i < this.sujectArray.length; i++) {
- this.sujectApis.push(this.sujectArray[i]);
- }
- this.$refs.popovers[0].doClose();
- },
- hideHandle() {},
- showHandle() {
- var array = [];
- for (let i = 0; i < this.sujectApis.length; i++) {
- if (
- this.sujectApis[i].split("-").map(Number)[0] === Number(this.courType)
- ) {
- array.push(this.sujectApis[i]);
- }
- }
- this.sujectArray = array;
- if (!this.newSujectOption.length) {
- this.$message.warning("该业务层次暂无关联科目");
- this.$refs.popovers[0].doClose();
- return;
- }
- this.newSujectOption.map((item) => {
- item.newId = this.courType + "-" + item.id;
- });
- this.handleCheckedCitiesChange();
- },
- closeType(index) {
- this.sujectApis.splice(index, 1);
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .checkboxSty {
- display: flex;
- flex-direction: column;
- }
- .listBoxStys {
- flex-shrink: 0;
- padding: 0px 10px;
- border-radius: 8px;
- border: 1px solid #eee;
- margin-right: 10px;
- margin-bottom: 6px;
- }
- .closeIcons {
- color: red;
- cursor: pointer;
- margin-left: 6px;
- }
- .ach {
- display: flex;
- align-items: center;
- overflow: hidden;
- }
- .clh {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- }
- </style>
|