KindergartenUI/src/views/system/testItemCountryScore/index.vue

812 lines
22 KiB
Vue
Raw Normal View History

<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="所属项目" prop="itemId">
<!-- this.queryParams.itemName=null -->
<el-input
v-model="queryParams.itemName"
placeholder="请输入所属项目"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="测试项目平均成绩" label-width="200">
<el-input
v-model="queryParams.itemAvgScore"
placeholder="请输入测试项目平均成绩"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item> -->
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:testItemCountryScore:add']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:testItemCountryScore:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:testItemCountryScore:remove']"
>删除</el-button
>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:testItemCountryScore:export']"
>导出</el-button
>
</el-col> -->
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="testItemCountryScoreList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="主键id" align="center" prop="id" /> -->
<el-table-column label="所属项目" align="center" prop="itemName" />
<el-table-column label="平均得分" align="center">
<!-- <template slot-scope="scope">
{{ fun(scope.row.itemAvgScore) }}
</template> -->
<template slot-scope="scope">
{{ scope.row.dictValue == "number" ? scope.row.itemAvgScore : "" }}
{{ scope.row.dictValue == "text" ? scope.row.itemAvgText : "" }}
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:testItemCountryScore:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:testItemCountryScore:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!--修改全国平均成绩对话框 -->
<el-dialog
:title="title"
:visible.sync="open2"
width="550px"
append-to-body
:before-close="cancel2"
>
<el-form
ref="form"
:model="form"
:rules="rulesxg"
label-width="80px"
style=""
>
<el-form-item label="所属项目" prop="itemId">
<el-button
type=""
@click="innerVisible = true"
v-if="xmname == '请选择所属项目'"
style="
width: 360px;
text-align: left;
height: 36px;
color: #c0c4cc;
padding-left: -10px;
"
>{{ xmname }}</el-button
>
<el-button
type=""
@click="innerVisible = true"
v-else
style="
width: 360px;
text-align: left;
height: 36px;
padding-left: -10px;
"
>{{ xmname }}</el-button
>
</el-form-item>
<el-form-item
label="平均得分"
prop="itemAvgScore"
v-if="form.dictValue == 'number'"
>
<el-input
v-model="form.itemAvgScore"
@input="NumberCheck2()"
style="width: 360px"
placeholder="请输入平均得分"
/>
</el-form-item>
<el-form-item
label="平均得分"
prop="itemAvgText"
v-if="form.dictValue == 'text'"
>
<el-input
v-model="form.itemAvgText"
placeholder="请输入平均得分"
style="width: 360px"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel2"> </el-button>
</div>
</el-dialog>
<!-- 添加全国平均成绩对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="550px"
append-to-body
:before-close="cancel"
>
<el-form
ref="form"
:model="form2"
:rules="rules"
label-width="80px"
style=""
>
<el-form-item label="所属项目" prop="itemId">
<el-button
type=""
@click="innerVisible = true"
v-if="xmname == '请选择所属项目'"
style="
width: 360px;
text-align: left;
height: 36px;
color: #c0c4cc;
padding-left: -10px;
"
>{{ xmname }}</el-button
>
<el-button
type=""
@click="innerVisible = true"
v-else
style="
width: 360px;
text-align: left;
height: 36px;
padding-left: -10px;
"
>{{ xmname }}</el-button
>
</el-form-item>
<el-form-item
label="平均得分"
prop="itemAvgScore"
v-if="form2.resultDictType == ''"
>
<el-input placeholder="请输入平均得分" style="width: 360px" />
</el-form-item>
<el-form-item
label="平均得分"
prop="itemAvgScore"
v-else-if="form2.resultDictType == 'number'"
>
<el-input
v-model="form2.itemAvgScore"
@input="NumberCheck()"
placeholder="请输入平均得分"
style="width: 360px"
/>
</el-form-item>
<el-form-item
label="平均得分"
prop="itemAvgText"
v-else-if="form2.resultDictType == 'text'"
>
<el-input
v-model="form2.itemAvgText"
placeholder="请输入平均得分"
style="width: 360px"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 项目弹窗 -->
<el-dialog
width="850px"
title="选择所属项目"
:visible.sync="innerVisible"
append-to-body
>
<el-form
:model="queryParams2"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="90px"
>
<el-form-item label="项目名称" prop="itemName">
<el-input
v-model="queryParams2.itemName"
placeholder="请输入项目名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery2"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
<el-table :data="testItemslists">
<el-table-column label="请选择" width="70" align="center">
<template slot-scope="scope">
<el-button
type="primary"
v-if="itemId2 == scope.row.id"
style="width: 15px; height: 15px"
circle
@click="xmclick(scope.row)"
></el-button>
<el-button
v-else
style="width: 15px; height: 15px"
circle
@click="xmclick(scope.row)"
></el-button>
</template>
</el-table-column>
<el-table-column
property="itemName"
label="项目名称"
width="150"
align="center"
>
</el-table-column>
<el-table-column
label="字典类型"
align="center"
prop="resultDictType"
>
<template slot-scope="scope">
{{
scope.row.resultDictType == ResultType1.dictCode
? ResultType1.dictLabel
: ""
}}{{
scope.row.resultDictType == ResultType2.dictCode
? ResultType2.dictLabel
: ""
}}</template
>
</el-table-column>
<el-table-column
property="itemCode"
label="测试项目编号"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="itemContent"
label="项目内容"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="mesureUnit"
label="项目度量单位"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="largeStandardScore"
label="大班标准最高得分"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="middleStandardScore"
label="中班标准最高得分"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="smallStandardScore"
label="小班标准最高得分"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="unifiedStandardScore"
label="统一标准最高得分"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="sorting"
label="排序"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="remark"
label="项目概述"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="createBy"
label="创建人"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="createTime"
label="创建时间"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="updateBy"
label="修改人"
width="150"
align="center"
>
</el-table-column>
<el-table-column
property="updateTime"
label="修改时间"
width="150"
align="center"
>
</el-table-column>
</el-table>
<pagination
v-show="total2 > 0"
:total="total2"
:page.sync="queryParams2.pageNum"
:limit.sync="queryParams2.pageSize"
@pagination="getList"
/>
</el-form>
</el-dialog>
</div>
</template>
<script>
import {
listTestItemCountryScore,
getTestItemCountryScore,
delTestItemCountryScore,
addTestItemCountryScore,
updateTestItemCountryScore,
testItemslist,
} from "@/api/system/testItemCountryScore";
import { tKindergartenInfo } from "@/api/system/kindergartenInfo";
export default {
name: "TestItemCountryScore",
data() {
var roleMoeny = (rule, value, callback) => {
if (Number.isNaN(Number.parseFloat(value))) {
callback(new Error("请输入"));
} else if (!this.form2.itemAvgScore) {
callback(new Error("不能为空"));
} else
if (this.form2.itemAvgScore * 1 > 99999999) {
callback(new Error("最大99999999")); // 限制最大额度
} else {
callback();
}
};
var roleMoeny2 = (rule, value, callback) => {
console.log(value);
if (Number.isNaN(Number.parseFloat(value))) {
callback(new Error("请输入数字"));
} else if (!this.form.itemAvgScore) {
callback(new Error("不能为空"));
} else if (this.form.itemAvgScore * 1 > 99999999) {
callback(new Error("最大99999999")); // 限制最大额度
} else {
callback();
}
};
return {
//项目测试类型
itemResultType: "item_result_type",
//字典类型
itemResultTypelist: [],
ResultType1: "", //numberLeixing
ResultType2: "", //textleixing
// 遮罩层
loading: true,
innerVisible: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
//xiangmuname
xmname: "请选择所属项目",
// 总条数
total: 0,
total2: 0,
//xiangmu
testItemslists: [],
// 全国平均成绩表格数据
testItemCountryScoreList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
open2: false,
// 查询参数
itemId2: "",
itemId: "",
queryParams: {
pageNum: 1,
pageSize: 10,
itemName: null,
},
queryParams2: {
pageNum: 1,
pageSize: 10,
itemCategoryId: "",
itemName: "",
itemCode: "",
},
// 表单参数
form: {},
form2: {},
// 表单校验
rulesxg: {
itemAvgScore: [{ required: true, validator: roleMoeny2, message: "", trigger: "blur"}],
},
rules: {
itemId: [{ required: true }],
itemAvgScore: [ { required: true, validator: roleMoeny, message: "",trigger: "blur" }],
itemAvgText: [
{ required: true, message: "请输入平均得分", trigger: "blur" },
],
},
};
},
created() {
this.getList();
},
methods: {
//添加的只能保留一个小数点
NumberCheck(num) {
let str = this.form2.itemAvgScore;
//限制只能输入一个小数点
if (str.indexOf(".") != -1) {
var str_ = str.substr(str.indexOf(".") + 1);
if (str_.indexOf(".") != -1) {
str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
}
}
//正则替换,保留数字和小数点
str = str.replace(/[^\d^\.]+/g,'')
this.form2.itemAvgScore=str
},
NumberCheck2(num) {
let str = this.form.itemAvgScore;
//限制只能输入一个小数点
if (str.indexOf(".") != -1) {
var str_ = str.substr(str.indexOf(".") + 1);
if (str_.indexOf(".") != -1) {
str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
}
}
//正则替换,保留数字和小数点
str = str.replace(/[^\d^\.]+/g,'')
this.form.itemAvgScore=str
},
// // fun(val) {
// // return Number(val).toFixed(2);
// },
xmclick(row) {
console.log(row);
this.xmname = row.itemName;
this.itemId2 = row.id;
this.form.itemId = row.id;
this.form2.itemId = row.id;
this.innerVisible = false;
this.form.itemName = row.itemName;
if (row.resultDictType == this.ResultType1.dictCode) {
this.form2.resultDictType = this.ResultType1.dictValue;
this.form.dictValue = this.ResultType1.dictValue;
this.form2.itemAvgText = "";
}
if (row.resultDictType == this.ResultType2.dictCode) {
this.form2.resultDictType = this.ResultType2.dictValue;
this.form.dictValue = this.ResultType2.dictValue;
this.form.itemAvgScore = "";
this.form2.itemAvgScore = "";
}
console.log(this.form);
console.log(this.form2);
},
/** 查询全国平均成绩列表 */
getList() {
this.loading = true;
testItemslist(this.queryParams2).then((res) => {
this.testItemslists = res.rows;
console.log(this.testItemslists);
this.total2 = res.total;
});
listTestItemCountryScore(this.queryParams).then((response) => {
this.testItemCountryScoreList = response.rows;
this.total = response.total;
this.loading = false;
});
tKindergartenInfo(this.itemResultType).then((res) => {
// console.log(res);
this.itemResultTypelist = res.data;
this.ResultType1 = this.itemResultTypelist[0];
this.ResultType2 = this.itemResultTypelist[1];
// console.log(this.ResultType1);
});
},
// 取消按钮
cancel2() {
this.open2 = false;
this.xmname = "请选择所属项目";
this.reset();
},
cancel() {
this.open = false;
this.xmname = "请选择所属项目";
this.itemId2 = "";
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
itemId: null,
itemAvgScore: "",
itemAvgText: "",
resultDictType: "", //number text
};
this.form2 = {
itemId: null,
itemAvgScore: "",
itemAvgText: "",
resultDictType: "", //number text
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery2() {
this.queryParams2.pageNum = 1;
testItemslist(this.queryParams).then((response) => {
this.testItemslist = response.rows;
this.total = response.total;
this.loading = false;
this.getList();
});
},
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.handleQuery2();
this.queryParams.itemName = "";
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加全国平均成绩";
this.itemId2 = "";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.itemId2 = row.itemId;
// console.log(row);
this.reset();
const id = row.id || this.ids;
getTestItemCountryScore(id).then((response) => {
this.form = response.data;
this.xmname = row.itemName;
this.open2 = true;
this.title = "修改全国平均成绩";
console.log(this.form);
});
},
/** 提交按钮 */
submitForm() {
if (this.form.dictValue == this.ResultType1.dictValue) {
console.log(this.ResultType1.dictValue);
this.form.itemAvgText = "";
}
if (this.form.dictValue == this.ResultType2.dictValue) {
console.log(this.ResultType2.dictValue);
this.form.itemAvgScore = "";
}
console.log(this.form);
this.form2.itemAvgScore = Number(this.form2.itemAvgScore).toFixed(2);
console.log(this.form2.itemAvgScore);
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateTestItemCountryScore(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open2 = false;
this.getList();
});
} else {
addTestItemCountryScore(this.form2).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
this.itemId2 = "";
this.xmname="";
this.xmname="请选择所属项目";
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal
.confirm("是否确认删除全国平均成绩的数据项?")
.then(function () {
return delTestItemCountryScore(ids);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download(
"system/testItemCountryScore/export",
{
...this.queryParams,
},
`testItemCountryScore_${new Date().getTime()}.xlsx`
);
},
},
};
</script>