| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809 |
- <template>
- <!-- 动力标准指标制定 -->
- <div class="powerStandardIndex">
- <div class="box">
- <div class="box-top">
- <el-form
- style="overflow: hidden;"
- :style="filterForm.show ? null : { height: '0px' }"
- size="mini"
- label-width="85px"
- >
- <el-row>
- <el-col :span="6">
- <el-form-item label="监测部门">
- <el-select
- filterable clearable
- v-model="filterForm.data.detectiondepartment"
- placeholder=""
- style="width: 100%;"
- >
- <el-option
- v-for="item of nameObj.detectiondepartment.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="系统名称">
- <el-select
- filterable clearable
- v-model="filterForm.data.systemname"
- placeholder=""
- style="width: 100%;"
- >
- <el-option
- v-for="item of nameObj.systemname.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="制定年度">
- <el-date-picker
- type="year"
- v-model="filterForm.data.creatyear"
- placeholder=""
- style="width: 100%;"
- format="yyyy"
- value-format="yyyy"
- ></el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="监测点名称">
- <el-select
- filterable clearable
- v-model="filterForm.data.powermonitorname"
- placeholder=""
- style="width: 100%;"
- >
- <el-option
- v-for="item of nameObj.powermonitorname.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="6">
- <el-form-item label="监测项目名称">
- <el-select
- filterable clearable
- v-model="filterForm.data.itemname"
- placeholder=""
- style="width: 100%;"
- >
- <el-option
- v-for="item of nameObj.itemname.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="box-top-gjl">
- <!-- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-plus"
- v-privilege="activeMenu + 'ADD'"
- @click="but_add"
- >新增</el-button> -->
- <div style="float:right; text-align: right;">
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-search"
- v-privilege="activeMenu + 'QUERY'"
- @click="getTableData(1)"
- >查询</el-button>
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-refresh"
- v-privilege="activeMenu + 'QUERY'"
- @click="tableDataCancel();"
- >重置</el-button>
- <el-button
- size="mini"
- :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
- :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
- @click="filterForm.show = !filterForm.show;
- $nextTick(() => {
- singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
- }
- );"
- >{{ filterForm.show ? '收起' : '展开' }}</el-button>
- </div>
- </div>
- </div>
- <div class="box-bottom">
- <el-table
- stripe
- id="singleTable"
- ref="singleTable"
- :data="tableData"
- v-loading="tableLoading"
- style="width: 100%;"
- :height="singleTableHeight"
- border
- size="mini"
- highlight-current-row
- >
- <el-table-column
- sortable
- :sort-by="function(row, index) { return sortFoo(row, index, 'detectiondepartment') }"
- prop="detectiondepartment"
- label="监测部门"
- min-width="100px"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <span>{{ nameObj.detectiondepartment.obj[scope.row.detectiondepartment] ? nameObj.detectiondepartment.obj[scope.row.detectiondepartment] : scope.row.detectiondepartment }}</span>
- </template>
- </el-table-column>
- <el-table-column
- sortable
- prop="systemname"
- label="系统名称"
- min-width="100px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- sortable
- prop="powermonitorname"
- label="监测点名称"
- min-width="100px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- sortable
- prop="itemname"
- label="监测项目名称"
- min-width="100px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- sortable
- prop="upperlimit"
- label="标准指标上限"
- min-width="100px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- sortable
- prop="lowerlimit"
- label="标准指标下限"
- min-width="100px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- sortable
- prop="creatyear"
- label="制定年度"
- min-width="100px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- class-name="gn-TableDownloadExcel-none"
- label="操作"
- align="center"
- width="75px"
- fixed="right"
- >
- <template slot-scope="scope">
- <div>
- <el-button
- type="primary"
- size="mini"
- v-privilege="activeMenu + 'PUT'"
- @click="but_edit(scope.row)"
- >修改</el-button>
- <!-- <el-button
- type="danger"
- size="mini"
- v-privilege="activeMenu + 'DELETE'"
- @click="but_del(scope.row)"
- >删除</el-button> -->
- </div>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- :page-sizes="[10, 20, 50, 100, 500, 1000]"
- :page-size="pageSize"
- :current-page.sync="pageNum"
- @size-change="tableSizeChange"
- @current-change="getTableData()"
- style="text-align: right;margin-top: 10px;"
- ></el-pagination>
- </div>
- </div>
- <el-dialog
- :title="'信息 - ' + (dialog.editorBox.type === 'add' ? '新增' : '修改')"
- :visible.sync="dialog.editorBox.show"
- width="600px"
- :close-on-click-modal="false"
- :show-close="!loading"
- >
- <div>
- <el-form
- ref="dialog_form"
- :model="dialog.editorBox.form.data"
- :rules="dialog.editorBox.form.rules"
- size="mini"
- label-width="90px"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="监测部门"
- prop="detectiondepartment"
- >
- <el-select
- filterable clearable
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.detectiondepartment"
- >
- <el-option
- v-for="item of nameObj.detectiondepartment.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="系统名称"
- prop="systemname"
- >
- <el-select
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.systemname"
- >
- <el-option
- v-for="item of nameObj.systemname.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="监测点名称"
- prop="powermonitorname"
- >
- <el-select
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.powermonitorname"
- >
- <el-option
- v-for="item of nameObj.powermonitorname.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="监测项目名称"
- prop="itemname"
- >
- <el-select
- filterable clearable
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.itemname"
- >
- <el-option
- v-for="item of nameObj.itemname.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="标准指标上限"
- prop="upperlimit"
- >
- <el-input clearable
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.upperlimit"
- >
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="标准指标下限"
- prop="lowerlimit"
- >
- <el-input clearable
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.lowerlimit"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="制定年度"
- prop="creatyear"
- >
- <el-date-picker
- type="year"
- v-model="dialog.editorBox.form.data.creatyear"
- placeholder=""
- style="width: 100%;"
- format="yyyy"
- value-format="yyyy"
- ></el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="单位"
- prop="unitname"
- >
- <el-input clearable
- style="width: 100%;"
- v-model="dialog.editorBox.form.data.unitname"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <span
- slot="footer"
- class="dialog-footer"
- >
- <el-button
- @click="dialog.editorBox.show = false"
- :loading="loading"
- >取 消</el-button>
- <el-button
- type="primary"
- @click="dataSave"
- :loading="loading"
- >保 存</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { zCheckNumber1 } from '@/utils/validator.js'
- export default {
- name: 'powerStandardIndex',
- data () {
- return {
- activeMenu: '',
- filterForm: {
- show: true,
- data: {
- detectiondepartment: '',
- systemname: '',
- creatyear: '',
- powermonitorname: '',
- itemname: ''
- },
- rules: {
- }
- },
- pageNum: 1,
- pageSize: 20,
- total: 0,
- singleTableHeight: 100,
- tableData: [
- // {
- // detectiondepartment: '',
- // systemname: '',
- // powermonitorname: '',
- // itemname: '',
- // upperlimit: '',
- // lowerlimit: '',
- // creatyear: '',
- // unitname: ''
- // }
- ],
- nameObj: {
- detectiondepartment: {
- obj: {
- 'TestCenter': '检化验中心',
- 'CentreWaterTreatment': '中央水处理'
- },
- arr: [
- {
- id: 'TestCenter',
- name: '检化验中心'
- },
- {
- id: 'CentreWaterTreatment',
- name: '中央水处理'
- }
- ]
- },
- systemname: {
- obj: {},
- arr: []
- },
- powermonitorname: {
- obj: {},
- arr: []
- },
- itemname: {
- obj: {},
- arr: []
- }
- },
- loading: false,
- tableLoading: false,
- dialog: {
- editorBox: {
- show: false,
- type: '',
- form: {
- data: {
- detectiondepartment: '',
- systemname: '',
- powermonitorname: '',
- itemname: '',
- upperlimit: '',
- lowerlimit: '',
- creatyear: '',
- unitname: ''
- },
- rules: {
- detectiondepartment: [
- { required: true, message: '该项不能为空', trigger: 'change' }
- ],
- systemname: [
- { required: true, message: '该项不能为空', trigger: 'change' }
- ],
- powermonitorname: [
- { required: true, message: '该项不能为空', trigger: 'change' }
- ],
- itemname: [
- { required: true, message: '该项不能为空', trigger: 'change' }
- ],
- upperlimit: [
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- lowerlimit: [
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- creatyear: [],
- unitname: []
- }
- }
- }
- }
- }
- },
- created () {
- this.activeMenu = window.localStorage.getItem('activeMenu');
- },
- mounted () {
- let that = this;
- window.PEDataObj = {
- // 将数据绑定到window上,供main页面使用
- vm: that,
- // tableArr:用于导出成Excel的表格的信息
- tableArr: [
- {
- name: '',
- id: 'singleTable'
- }
- ]
- };
- that.$nextTick(() => {
- // 立即获取的height有一定偏差,通过setTimeout延迟来解决
- setTimeout(() => {
- that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
- }, 1);
- });
- that.getSystemNameData();
- that.getPowermonitorNameData();
- that.getItemNameData();
- that.getTableData();
- },
- methods: {
- // 计算树区域高度
- getRoleHeight (dom) {
- return window.innerHeight - dom.offsetTop;
- },
- // 获取系统名称
- getSystemNameData () {
- let that = this
- let url = 'pass/ems/v1/tcm0325s/getidandname/';
- that.axios.get(url)
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- let obj = {};
- for (let item of res.data) {
- arr.push({
- id: item.powercode,
- name: item.powername
- })
- obj[item.powercode] = item.powername;
- }
- that.nameObj.systemname.arr = arr;
- that.nameObj.systemname.obj = obj;
- } else {
- that.$message.error(res.message);
- }
- });
- },
- // 获取监测点名称
- getPowermonitorNameData () {
- let that = this
- let url = 'pass/ems/v1/tcm0316s/getidandname/';
- that.axios.get(url)
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- let obj = {};
- for (let item of res.data) {
- arr.push({
- id: item.id,
- name: item.name
- })
- obj[item.id] = item.name;
- }
- that.nameObj.powermonitorname.arr = arr;
- that.nameObj.powermonitorname.obj = obj;
- } else {
- that.$message.error(res.message);
- }
- });
- },
- // 获取监测项目
- getItemNameData () {
- let that = this
- let url = 'pass/ems/v1/tcm0323s/getidandname/';
- that.axios.get(url)
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- let obj = {};
- for (let item of res.data) {
- arr.push({
- id: item.id,
- name: item.name
- })
- obj[item.id] = item.name;
- }
- that.nameObj.itemname.arr = arr;
- that.nameObj.itemname.obj = obj;
- } else {
- that.$message.error(res.message);
- }
- });
- },
- // 获取表格中的数据
- getTableData (pageNum) {
- let that = this,
- params = {
- detectiondepartment: that.filterForm.data.detectiondepartment,
- systemname: that.filterForm.data.systemname,
- creatyear: that.filterForm.data.creatyear,
- powermonitorname: that.filterForm.data.powermonitorname,
- itemname: that.filterForm.data.itemname
- };
- that.pageNum = pageNum || that.pageNum;
- that.tableLoading = true;
- let url = 'pass/ems/v1/tcm0324s/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
- that.axios.get(url, {
- params: params
- })
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- for (let item of res.data.list) {
- arr.push({
- detectiondepartment: item.detectiondepartment,
- systemname: item.systemname,
- powermonitorname: item.powermonitorname,
- itemname: item.itemname,
- upperlimit: item.upperlimit,
- lowerlimit: item.lowerlimit,
- creatyear: item.creatyear,
- unitname: item.unitname
- })
- }
- that.tableData = arr;
- that.total = res.data.total;
- } else {
- that.$message.error(res.message);
- }
- that.tableLoading = false;
- }).catch(function () {
- that.tableLoading = false;
- });
- },
- // 改变表格显示条数
- tableSizeChange (val) {
- let that = this;
- that.pageSize = val;
- that.getTableData(1);
- },
- // 重置搜索
- tableDataCancel () {
- let that = this;
- for (let key in that.filterForm.data) {
- if (that.filterForm.data[key] instanceof Array) {
- that.filterForm.data[key] = [];
- } else {
- that.filterForm.data[key] = '';
- }
- }
- that.getTableData(1);
- },
- but_add () {
- let that = this;
- for (let key in that.dialog.editorBox.form.data) {
- that.dialog.editorBox.form.data[key] = '';
- }
- that.dialog.editorBox.type = 'add';
- that.dialog.editorBox.show = true;
- setTimeout(() => {
- that.$refs['dialog_form'].clearValidate();
- }, 100);
- },
- but_edit (row) {
- let that = this;
- for (let key in that.dialog.editorBox.form.data) {
- if (typeof row[key] !== 'undefined') {
- that.dialog.editorBox.form.data[key] = row[key];
- }
- }
- that.dialog.editorBox.type = 'edit';
- that.dialog.editorBox.show = true;
- },
- but_del (row) {
- let that = this;
- that.$confirm('是否删除该条数据?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- state: 'warning'
- }).then(() => {
- that.axios.delete('pass/ems/v1//?powercode=' + row.powercode + '&sort=' + row.sort)
- .then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: '删除成功',
- type: 'success'
- });
- that.getTableData();
- } else {
- that.$message.error(res.message);
- }
- }).catch(function () {
- });
- }).catch(() => {
- });
- },
- dataSave () {
- let that = this;
- let SubmitData = {
- detectiondepartment: that.dialog.editorBox.form.data.detectiondepartment,
- systemname: that.dialog.editorBox.form.data.systemname,
- powermonitorname: that.dialog.editorBox.form.data.powermonitorname,
- itemname: that.dialog.editorBox.form.data.itemname,
- upperlimit: that.dialog.editorBox.form.data.upperlimit,
- lowerlimit: that.dialog.editorBox.form.data.lowerlimit,
- creatyear: that.dialog.editorBox.form.data.creatyear,
- unitname: that.dialog.editorBox.form.data.unitname
- };
- that.$refs['dialog_form'].validate((valid) => {
- if (valid) {
- if (that.dialog.editorBox.type === 'add') {
- let foorData = new FormData();
- for (let key in SubmitData) {
- foorData.append(key, SubmitData[key]);
- }
- that.loading = true;
- that.axios.post('pass/ems/v1//', foorData, {
- headers: {
- 'Content-Type': 'multipart/form-data'
- }
- })
- .then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: '新增成功',
- type: 'success'
- });
- that.getTableData();
- that.dialog.editorBox.show = false;
- } else {
- that.$message.error(res.message);
- }
- that.loading = false;
- }).catch(function () {
- that.loading = false;
- });
- } else {
- that.loading = true;
- that.axios.put('pass/ems/v1/tcm0324s/', SubmitData)
- .then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: '修改成功',
- type: 'success'
- });
- that.getTableData();
- that.dialog.editorBox.show = false;
- } else {
- that.$message.error(res.message);
- }
- that.loading = false;
- }).catch(function () {
- that.loading = false;
- });
- }
- }
- });
- }
- }
- }
- </script>
- <style lang="less">
- .powerStandardIndex {
- min-width: 700px;
- height: 100%;
- .box {
- height: 100%;
- padding: 15px 15px 0 15px;
- .box-top {
- .el-form-item {
- margin-bottom: 7px;
- }
- .box-top-gjl {
- overflow: hidden;
- padding: 7px 0;
- border-top: 1px solid #ccc;
- // border-bottom: 1px solid #ccc;
- // margin-bottom: 6px;
- }
- }
- }
- }
- </style>
|