| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- <template>
- <div id="examNum">
- <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="pageSize"
- :currentPage="currentPage"
- @handleSizeChange="handleSizeChange"
- @handleCurrentChange="handleCurrentChange"
- />
- <el-dialog
- @closed="loadingClose"
- :visible.sync="dialogVisible"
- width="560px"
- :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="150px"
- :model="listData"
- :rules="rules"
- ref="listData"
- >
- <el-form-item label="商品类型" prop="goodsType">
- <el-select
- v-model="listData.goodsType"
- placeholder="请选择"
- disabled
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="业务层级" prop="educationTypeId">
- <el-select
- v-model="listData.educationTypeId"
- placeholder="选择教育类型"
- @change="listData.businessId = ''"
- :disabled="statusPop === 0"
- >
- <el-option
- v-for="item in educationType"
- :key="item.id"
- :label="item.educationName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label=""
- prop="businessId"
- v-if="listData.educationTypeId"
- >
- <el-select
- v-model="listData.businessId"
- :disabled="statusPop === 0"
- placeholder="选择业务层次"
- >
- <el-option
- v-for="item in businessList"
- :key="item.id"
- :label="item.projectName + '-' + item.businessName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="适用商品" prop="goodsId">
- <span v-if="!listData.businessId" style="color: #f56c6c"
- >请先选择业务层级</span
- >
- <el-checkbox-group
- v-model="listData.goodsId"
- v-else-if="listData.businessId && goodsList.length"
- >
- <el-checkbox
- v-for="(item, index) in goodsList"
- :key="index"
- :label="item.goodsId"
- :disabled="
- item.goodsStatus === 0 &&
- bfListData.goodsId.indexOf(item.goodsId) === -1
- "
- >{{ item.code + "-" + item.goodsName + "-" }}
- <span
- :style="
- item.goodsStatus === 0 &&
- bfListData.goodsId.indexOf(item.goodsId) === -1
- ? ''
- : 'color:#F56C6C'
- "
- >¥{{ item.standPrice }}</span
- ></el-checkbox
- >
- </el-checkbox-group>
- <span style="color: #f56c6c" v-else>该业务层级下,无适用商品</span>
- </el-form-item>
- <el-form-item label="考试次数" prop="examNumber"
- ><el-input-number
- :controls="false"
- :disabled="statusPop === 2"
- v-model="listData.examNumber"
- :precision="0"
- ></el-input-number
- ></el-form-item>
- <el-form-item label="前培(刷题)次数" prop="doNumber"
- ><el-input-number
- :controls="false"
- :disabled="statusPop === 2"
- v-model="listData.doNumber"
- :precision="0"
- ></el-input-number
- ></el-form-item>
- <el-form-item label="状态" prop="">
- <el-radio-group v-model="listData.status">
- <el-radio
- v-for="(item, index) in statusOptions"
- :key="index"
- :label="item.value"
- :disabled="statusPop === 2"
- >{{ item.label }}</el-radio
- >
- </el-radio-group>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="close">取 消</el-button>
- <el-button
- type="primary"
- :loading="disabledBtn"
- v-if="statusPop !== 2"
- @click="submit('listData')"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import searchBox from "@/components/searchBox";
- import tableList from "@/components/tableList";
- import pagination from "@/components/pagination";
- export default {
- name: "ExamNum",
- components: { searchBox, tableList, pagination },
- data() {
- return {
- disabledBtn: false,
- loading: false, //当前表单加载是否加载动画
- navText: {
- title: "配置考试次数前培次数",
- index: 0,
- ch: "条",
- num: true,
- choice: false,
- border: true,
- addHide: false,
- backFatherBtn: {
- status: false,
- title: "未定义",
- },
- },
- // 表单
- tableSet: [
- {
- label: "考次编码",
- prop: "code",
- hidden: true,
- },
- {
- label: "商品类型",
- prop: "goodsType",
- hidden: true,
- scope: "isOptions",
- options: [
- {
- label: "视频",
- value: 1,
- },
- {
- label: "题库",
- value: 2,
- },
- {
- label: "补考",
- value: 3,
- },
- {
- label: "前培",
- value: 4,
- },
- ],
- },
- {
- label: "教育类型",
- prop: "educationName",
- hidden: true,
- },
- {
- label: "业务层次",
- prop1: "projectName",
- prop2: "businessName",
- scope: "InfoMore",
- hidden: true,
- },
- {
- label: "适配商品",
- prop: "examNumberGoodsVos",
- prop1: "code",
- prop2: "goodsName",
- prop3: "standPrice",
- hidden: true,
- scope: "moreGoodsList",
- },
- {
- label: "考试次数",
- prop: "examNumber",
- hidden: true,
- },
- {
- label: "前培(刷题)次数",
- prop: "doNumber",
- hidden: true,
- },
- {
- label: "状态",
- prop: "status",
- hidden: true,
- scope: "status",
- },
- ],
- tableData: [], //表单数据
- total: 0, //一共多少条
- pageSize: 10, //每页多少条数据
- currentPage: 1, //当前页码
- // 弹窗数据
- listData: {
- examNumber: 0,
- doNumber: 0,
- },
- statusPop: -1,
- dialogVisible: false,
- options: [
- {
- label: "视频",
- value: 1,
- },
- {
- label: "题库",
- value: 2,
- },
- {
- label: "补考",
- value: 3,
- },
- {
- label: "前培",
- value: 4,
- },
- ],
- statusOptions: [
- {
- label: "启用",
- value: 1,
- },
- {
- label: "关闭",
- value: 0,
- },
- ],
- //表单验证
- rules: {
- goodsType: [
- { required: true, message: "请选择商品类型", trigger: "change" },
- ],
- educationTypeId: [
- { required: true, message: "请选择教育类型", trigger: "change" },
- ],
- businessId: [
- { required: true, message: "请选择业务层次", trigger: "change" },
- ],
- goodsId: [
- {
- type: "array",
- required: true,
- message: "请至少选择一个商品",
- trigger: "change",
- },
- ],
- examNumber: [
- {
- required: true,
- type: "number",
- min: 0,
- message: "请重新输入考试次数",
- trigger: "blur",
- },
- ],
- doNumber: [
- {
- required: true,
- type: "number",
- min: 0,
- message: "请重新输入前培(刷题)次数",
- trigger: "blur",
- },
- ],
- status: [{ required: true, message: "请选择状态", trigger: "change" }],
- },
- busList: [],
- businessList: [],
- goodsList: [],
- bfListData: {},
- examNumber: 0,
- doNumber: 0,
- };
- },
- computed: { ...mapGetters(["educationType"]) },
- mounted() {
- this.getDict();
- this.search();
- },
- activated() {
- this.getDict();
- this.search();
- },
- watch: {
- "listData.educationTypeId"(value) {
- this.businessList = this.busList.filter((item) => {
- return item.educationId == value;
- });
- },
- "listData.businessId"(value) {
- if (value) {
- if (this.statusPop === 1) {
- this.listData.goodsId = [];
- }
- this.$api
- .inquiresystemnumberlistGoods({ businessId: value, goodsType: 1 })
- .then((res) => {
- this.goodsList = res.rows;
- });
- }
- },
- },
- methods: {
- loadingClose() {
- this.disabledBtn = false;
- },
- getDict() {
- this.$api.inquirebusinessList({ status: 1 }).then((res) => {
- this.busList = res.rows;
- });
- },
- editInfo(v) {
- this.addClick(v, 0);
- },
- search(v) {
- this.loading = true;
- var data = {
- status: "0,1",
- pageSize: this.pageSize,
- pageNum: this.currentPage,
- };
- this.$api
- .inquiresystemnumber(data)
- .then((res) => {
- this.tableData = res.rows;
- this.total = res.total;
- this.navText.index = res.total;
- })
- .finally(() => {
- this.loading = false;
- });
- },
- init() {
- this.search();
- },
- del(v) {
- this.$alert(
- "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
- "提示",
- {
- dangerouslyUseHTMLString: true,
- }
- )
- .then(() => {
- var data = {
- examNumberId: v.examNumberId,
- status: -1,
- };
- this.$api.editsystemnumber(data).then((res) => {
- this.$message.success("删除成功");
- this.search();
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消删除",
- });
- });
- },
- addClick(v, int) {
- if (v === undefined) {
- this.goodsList = [];
- this.statusPop = 1;
- this.examNumber = 0;
- this.doNumber = 0;
- this.bfListData = {
- goodsId: [],
- };
- this.listData = {
- goodsType: 1,
- status: 1,
- businessId: "",
- goodsId: [],
- examNumber: 0,
- doNumber: 0,
- };
- this.rules.examNumber[0].min = 0;
- this.rules.doNumber[0].min = 0;
- this.rules.examNumber[0].message = "考试次数不得小于" + 0 + "次";
- this.rules.doNumber[0].message = "前培次数不得小于" + 0 + "次";
- this.$nextTick(() => {
- this.$refs.listData.clearValidate();
- });
- this.dialogVisible = true;
- } else {
- this.statusPop = int;
- this.$api.obtainsystemnumber(v.examNumberId).then((res) => {
- this.$api
- .inquiresystemnumberlistGoods({
- businessId: res.data.businessId,
- goodsType: 1,
- })
- .then((result) => {
- this.goodsList = result.rows;
- });
- this.bfListData = JSON.parse(JSON.stringify(res.data));
- this.rules.examNumber[0].min = this.bfListData.examNumber;
- this.rules.examNumber[0].message =
- "考试次数不得小于" + this.bfListData.examNumber + "次";
- this.rules.doNumber[0].min = this.bfListData.doNumber;
- this.rules.doNumber[0].message =
- "前培次数不得小于" + this.bfListData.doNumber + "次";
- this.examNumber = this.bfListData.examNumber;
- this.doNumber = this.bfListData.doNumber;
- this.listData = res.data;
- this.$nextTick(() => {
- this.$refs.listData.clearValidate();
- });
- this.dialogVisible = true;
- });
- }
- },
- submit(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.rulesTableSumbit();
- } else {
- return false;
- }
- });
- },
- rulesTableSumbit() {
- this.disabledBtn = true;
- var data = JSON.parse(JSON.stringify(this.listData));
- this.busList.map((item) => {
- if (item.id === data.businessId) {
- data.projectId = item.projectId;
- }
- });
- if (this.statusPop === 1) {
- this.$api
- .appsystemnumber(data)
- .then((res) => {
- this.$message.success("新增成功");
- this.dialogVisible = false;
- this.search();
- })
- .catch(() => {
- this.disabledBtn = false;
- });
- }
- if (this.statusPop === 0) {
- this.$api
- .editsystemnumber(data)
- .then((res) => {
- this.$message.success("修改成功");
- this.dialogVisible = false;
- this.search();
- })
- .catch(() => {
- this.disabledBtn = false;
- });
- }
- },
- close() {
- this.dialogVisible = false;
- },
- handleSizeChange(v) {
- this.pageSize = v;
- this.currentPage = 1;
- this.search();
- },
- handleCurrentChange(v) {
- this.currentPage = v;
- this.search();
- },
- },
- };
- </script>
- <style lang="less" scoped>
- /deep/ .el-checkbox-group {
- max-height: 260px;
- overflow-y: auto;
- border: 1px solid #eee;
- padding: 10px;
- }
- /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;
- }
- }
- </style>
|