123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881 |
- <template>
- <div id="knowledgeManagement">
- <search-box-new
- ref="searchBox"
- :formData="formData"
- :formList="formList"
- @search="search"
- @init="init"
- />
- <table-list
- :tableSets="tableSet"
- :tableData="tableData"
- :navText="navText"
- @addClick="addClick"
- :loading="loading"
- @editInfo="editInfo"
- >
- <template slot="btn" slot-scope="props">
- <el-button type="text" @click="addClick(props.scope.row, 0)"
- >修改</el-button
- >
- <el-button type="text" @click="del(props.scope.row)">删除</el-button>
- </template>
- </table-list>
- <pagination
- :total="total"
- :pageSize="formData.pageSize"
- :currentPage="formData.pageNum"
- @handleSizeChange="handleSizeChange"
- @handleCurrentChange="handleCurrentChange"
- />
- <el-dialog
- @closed="loadingClose"
- :visible.sync="dialogVisible"
- width="790px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">
- {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
- </div>
- <div class="rightBoxs">
- <img src="@/assets/images/Close@2x.png" alt="" @click="close" />
- </div>
- </div>
- <div>
- <el-form
- label-position="right"
- label-width="110px"
- :model="listData"
- ref="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>
- <span style="margin-left: 10px">注:可多选</span>
- </div>
- <div v-else-if="items.scope === 'activeBox'">
- <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 && statusPop === 1"
- 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>
- <div v-else>
- <div v-if="statusPop === 0">
- <el-input v-model="listData.knowledgeName"></el-input>
- </div>
- <div v-else>
- <el-input
- style="width: 40%; margin-right: 10px"
- v-model="BusName"
- ></el-input
- ><el-button @click="addBusName">添加</el-button>
- <!-- <div v-if="!BusNameList.length">请在下面输入框添加知识点</div> -->
- <ul class="BusBoxs">
- <li
- class="fot_Le"
- v-for="(item, index) in BusNameList"
- :key="index"
- >
- {{ item }}
- <i
- class="el-icon-error icon_clear"
- @click="clearBusName(index)"
- ></i>
- </li>
- <div style="clear: both"></div>
- </ul>
- </div>
- </div>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="close">取 消</el-button>
- <el-button type="primary" @click="submit" :loading="disabledBtn"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import searchBoxNew from "@/components/searchBoxNew";
- import tableList from "@/components/tableList";
- import pagination from "@/components/pagination";
- export default {
- name: "KnowledgeManagement",
- components: { searchBoxNew, tableList, pagination },
- data() {
- return {
- disabledBtn: false,
- isIndeterminate: false,
- checkAll: false,
- loading: false, //当前表单加载是否加载动画
- navText: {
- title: "知识点",
- index: 0,
- ch: "条",
- num: false,
- border: true,
- choice: true,
- addHide: false,
- backFatherBtn: {
- status: false,
- title: "未定义",
- },
- },
- //搜索
- formList: [
- {
- prop: "educationId",
- placeholder: "教育类型",
- scope: "educationType",
- },
- {
- prop: "businessId",
- placeholder: "业务层次",
- scope: "businessLevel",
- edu: "educationId",
- },
- {
- prop: "subjectId",
- placeholder: "科目",
- scope: "sujectType",
- edu: "educationId",
- },
- {
- prop: "knowledgeName",
- placeholder: "请输入知识点名称",
- },
- ],
- formData: {
- status: "0,1",
- pageSize: 10,
- pageNum: 1,
- },
- // 表单
- tableSet: [
- {
- label: "知识点编码",
- prop: "encoder",
- hidden: true,
- width: "140px",
- },
- {
- label: "知识点标题",
- prop: "knowledgeName",
- scope: "editInfo",
- hidden: true,
- },
- {
- label: "适用业务层级",
- prop: "courseBusinessList",
- hidden: true,
- scope: "mapTypesMores",
- },
- {
- label: "最后编辑时间",
- prop: "updateTime",
- scope: "aTimeList",
- hidden: true,
- },
- {
- label: "创建时间",
- prop: "createTime",
- scope: "aTimeList",
- hidden: true,
- },
- ],
- eduTypeOptions: [], //教育类型数据
- projectTypeOptions: [], //项目类型数据
- courTypeOptions: [], //业务层次数据
- newCourTypeOptions: [], //当前业务层次数据
- sujectOption: [], //科目数据
- newSujectOption: [], //当前科目数据数据
- eduType: "", //当前选中教育类型
- courType: "", //当前选中业务层次
- sujectApis: [], //当前存在的科目
- newSujectApis: [],
- sujectArray: [], //选中的科目
- BusName: "", //标签名称
- BusNameList: [], //标签列表
- tableData: [], //表单数据
- total: 0, //一共多少条
- changeHeight: false,
- listData: {},
- listitem: [
- {
- label: "适用业务层级",
- scope: "buss",
- },
- {
- label: "",
- scope: "activeBox",
- },
- {
- label: "知识点",
- },
- ],
- statusPop: 1,
- dialogVisible: false,
- localData: [],
- };
- },
- watch: {
- sujectApis: {
- immediate: true,
- handler(newName, oldName) {
- this.changeTypes();
- },
- },
- },
- mounted() {
- this.localData = this.$methodsTools.getBusinessList();
- this.getDict();
- this.search();
- },
- activated() {
- this.localData = this.$methodsTools.getBusinessList();
- this.getDict();
- this.search();
- },
- methods: {
- loadingClose() {
- this.disabledBtn = false;
- },
- 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("请先选择业务层级");
- }
- },
- addBusName() {
- if (this.BusName.trim()) {
- this.BusNameList.push(this.BusName);
- this.BusName = "";
- } else {
- this.$message({
- message: "请输入知识点内容",
- type: "warning",
- duration: 1200,
- });
- this.BusName = "";
- }
- },
- 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 = {
- 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;
- });
- },
- editInfo(v) {
- this.addClick(v, 0);
- },
- //int === 1搜索 页码归1 int === 2重置 条件初始化
- search(int) {
- this.loading = true;
- if (int === 1) {
- this.formData.pageNum = 1;
- }
- if (int === 2) {
- this.formData = {
- status: "0,1",
- pageSize: 10,
- pageNum: 1,
- };
- }
- this.$api
- .inquireKnowledgeExamListS(this.formData)
- .then((res) => {
- this.tableData = res.rows;
- this.total = res.total;
- this.navText.index = res.total;
- })
- .finally(() => {
- this.loading = false;
- });
- },
- init() {
- this.search(2);
- },
- 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();
- },
- 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();
- },
- submit() {
- this.disabledBtn = true;
- if (!this.newSujectApis.length) {
- this.$message.warning("请添加业务层级");
- this.disabledBtn = false;
- return;
- }
- if (this.statusPop === 1) {
- if (!this.BusNameList.length) {
- this.$message.warning("请添加知识点");
- this.disabledBtn = false;
- return;
- }
- var dataInfos = {
- status: 1,
- examKnowledgeBusinessAddBoList: this.newSujectApis,
- knowledgeName: this.BusNameList,
- };
- this.$api
- .addKnowledgeExam(dataInfos)
- .then((res) => {
- this.$methodsTools.cacheBusinessList(this.newSujectApis);
- this.$message.success("添加成功");
- this.dialogVisible = false;
- this.search();
- this.localData = this.$methodsTools.getBusinessList();
- })
- .catch(() => {
- this.disabledBtn = false;
- });
- } else {
- if (!this.listData.knowledgeName) {
- this.$message.warning("请输入知识点名称");
- this.disabledBtn = false;
- return;
- }
- var dataInfos = {
- knowledgeName: this.listData.knowledgeName,
- status: this.listData.status,
- knowledgeId: this.listData.knowledgeId,
- examKnowledgeBusinessAddBoList: this.newSujectApis,
- };
- this.$api
- .editKnowledgeExam(dataInfos)
- .then((res) => {
- this.$message.success("修改成功");
- this.dialogVisible = false;
- this.search();
- })
- .catch(() => {
- this.disabledBtn = false;
- });
- }
- },
- del(v) {
- this.$alert(
- "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
- "提示",
- {
- dangerouslyUseHTMLString: true,
- }
- )
- .then(() => {
- var data = {
- knowledgeId: v.knowledgeId,
- status: -1,
- };
- this.$api.editKnowledgeExam(data).then((res) => {
- this.$message.success("删除成功");
- this.search();
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消删除",
- });
- });
- },
- 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();
- },
- addClick(v, int) {
- if (v === undefined) {
- this.statusPop = 1;
- this.listData = {};
- this.eduType = ""; //当前选中教育类型
- this.courType = ""; //当前选中业务层次
- this.sujectApis = []; //当前存在的科目
- this.newSujectApis = [];
- this.sujectArray = []; //选中的科目
- this.BusName = "";
- this.BusNameList = [];
- } else {
- this.statusPop = int;
- this.eduType = ""; //当前选中教育类型
- this.courType = ""; //当前选中业务层次
- this.BusName = "";
- this.BusNameList = [];
- var arrays = [];
- this.listData = v;
- v.courseBusinessList.map((item) => {
- arrays.push(item.businessId + "-" + item.subjectId);
- });
- this.sujectApis = arrays;
- }
- this.$nextTick(() => {
- this.changeHeight = true;
- });
- this.dialogVisible = true;
- },
- close() {
- this.dialogVisible = false;
- },
- closeType(index) {
- this.sujectApis.splice(index, 1);
- },
- clearBusName(index) {
- this.BusNameList.splice(index, 1);
- },
- handleSizeChange(v) {
- this.formData.pageSize = v;
- this.formData.pageNum = 1;
- this.search();
- },
- handleCurrentChange(v) {
- this.formData.pageNum = v;
- this.search();
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .checkboxSty {
- display: flex;
- flex-direction: column;
- }
- /deep/.el-button {
- border-radius: 8px;
- }
- /deep/.el-dialog {
- border-radius: 8px;
- .el-dialog__header {
- padding: 0;
- .hearders {
- height: 40px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0px 18px 0px 20px;
- border-bottom: 1px solid #e2e2e2;
- .leftTitle {
- font-size: 14px;
- font-weight: bold;
- color: #2f4378;
- }
- .rightBoxs {
- display: flex;
- align-items: center;
- img {
- width: 14px;
- height: 14px;
- margin-left: 13px;
- cursor: pointer;
- }
- }
- }
- }
- .el-dialog__footer {
- padding: 0;
- .dialog-footer {
- padding: 0px 40px;
- height: 70px;
- border-top: 1px solid #e2e2e2;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- }
- }
- }
- .imgBox {
- width: 100%;
- // height: 210px;
- border: 1px solid #e2e2e2;
- border-radius: 8px;
- padding: 8px 8px 3px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .imgLabel {
- flex: 1;
- width: 100%;
- border: 1px dotted #e2e2e2;
- color: #999;
- font-size: 14px;
- cursor: pointer;
- border-radius: 8px;
- .msPhoto {
- display: flex;
- justify-content: center;
- align-items: center;
- max-width: 100%;
- max-height: 270px;
- img {
- max-width: 100%;
- max-height: 270px;
- }
- }
- .imgbbx {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- i {
- font-weight: bold;
- margin: 14px 0;
- font-size: 24px;
- }
- }
- }
- p {
- margin: 5px 0px;
- }
- }
- .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;
- }
- .BusBoxs {
- min-height: 100px;
- border: 1px solid #a4a4a4;
- margin-bottom: 10px;
- border-radius: 8px;
- max-height: 280px;
- padding: 10px;
- overflow-y: auto;
- .fot_Le {
- border-radius: 12px;
- border: 1px solid yellowgreen;
- padding: 0px 10px;
- height: 30px;
- line-height: 30px;
- text-align: center;
- float: left;
- margin-right: 6px;
- margin-bottom: 6px;
- .icon_clear {
- margin-left: 2px;
- font-size: 15px;
- color: #f56c6c;
- cursor: pointer;
- }
- }
- }
- </style>
|