1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504 |
- <template>
- <!-- 年度计划编制(建材厂-水渣) -->
- <!-- 当有审核与取消审核权限时,默认其为审核人,审核人无法修改数据 -->
- <div class="outElectricity">
- <div class="box">
- <div class="box-top">
- <el-form
- style="overflow: hidden;"
- :style="filterForm.show ? null : { height: '0px' }"
- size="mini"
- label-width="75px"
- >
- <el-row>
- <el-col :span="5">
- <!-- <el-form-item label="工序">
- <el-select
- filterable clearable
- v-model="filterForm.data.networkid"
- multiple
- collapse-tags
- placeholder="轧钢厂 "
- style="width: 100%;"
- disabled
- @change="connn()"
- >
- <el-option
- v-for="item of nameObj.networkid.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="年份">
- <zj-timegran-date
- v-model="filterForm.data.yearmonth"
- style="width: 100%;"
- :timegranId="'YEAR'"
- :oneFoo="getTableData"
- :custom="1"
- ></zj-timegran-date>
- </el-form-item>
- </el-col>
- <el-col :span="5">
- </el-col>
- <el-col :span="5">
- </el-col>
- </el-row>
- </el-form>
- <div class="box-top-gjl">
- <el-form size="mini" label-width="75px">
- <el-row>
- <el-col :span="16">
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-plus"
- @click="but_add"
- :loading="loading"
- >新增</el-button>
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-plus"
- @click="but_copy"
- :loading="loading"
- v-if="butPrivilege.PUT && !isCheck"
- >复制</el-button>
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-edit-outline"
- @click="but_edit_plural()"
- :loading="loading"
- v-if="butPrivilege.PUT && !isCheck"
- >修改</el-button>
- <el-button
- class="button"
- type="danger"
- size="mini"
- icon="el-icon-delete"
- v-if="butPrivilege.PUT && !isCheck"
- @click="but_del_plural()"
- :loading="loading"
- >删除</el-button>
- </el-col>
- <el-col :span="8">
- <div style="float:right; text-align: right;">
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-search"
- v-if="butPrivilege.QUERY"
- @click="getTableData(1)"
- >查询</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>
- </el-col>
- </el-row>
- </el-form>
- </div>
- </div>
- <div class="box-bottom">
- <el-form
- size="mini"
- ref="dialog_form_arr"
- label-width="0px"
- :model="tableFormDataObj"
- >
- <el-table stripe
- id="singleTable"
- ref="singleTable"
- :data="tableData"
- v-loading="tableLoading"
- style="width: 100%;"
- :height="singleTableHeight"
- border
- size="mini"
- highlight-current-row
- @selection-change="handleSelectionChange"
- show-summary
- :summary-method="getSummaries"
- :span-method="arraySpanMethod"
- :row-class-name="tableRowClassName"
- @cell-click="cellClick"
- >
- <el-table-column
- type="selection"
- width="40"
- align="center"
- :selectable='checkboxT'
- fixed="left"
- class-name="cnspicuous"
- ></el-table-column>
- <el-table-column
- sortable
- prop="index"
- type="index"
- label="序号"
- fixed="left"
- width="50px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- prop="yearmonth"
- label="月份"
- fixed="left"
- width="80px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <!-- <el-table-column
- prop="productid"
- label="产品名称"
- fixed="left"
- width="160px"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <span>{{ nameObj.workprocid.obj[scope.row.productid] ? nameObj.workprocid.obj[scope.row.productid].name : scope.row.productid }}</span>
- </template>
- </el-table-column> -->
- <el-table-column
- fixed="left"
- prop="unit"
- label="计量单位"
- width="100px"
- :show-overflow-tooltip="true"
- ><template slot-scope="scope">
- <span>{{ nameObj.unitid.obj[scope.row.unit] ? nameObj.unitid.obj[scope.row.unit] : scope.row.unit }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="weight"
- label="矿渣粉"
- width="160px"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
- :prop="scope.row.seq + '.weight'"
- :rules="tableFormRules.weight"
- >
- <el-input clearable
- style="width: 100%;"
- v-model="tableFormDataObj[scope.row.seq].weight"
- refcous="true"
- @keydown.native="keyDown" :id="scope.$index + scope.column.id"
- @change="chnageSecondVal(scope.row.seq, tableFormDataObj[scope.row.seq].secondVal, scope.$index)"
- ></el-input>
- <template slot="error" slot-scope="scope">
- <p class="error" :title="scope.error">{{ scope.error }}</p>
- </template>
- </el-form-item>
- <span v-else>{{scope.row.weight}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="cjsj"
- label="创建时间"
- width="220px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- prop="cjr"
- label="创建人"
- width="160px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- prop="xgsj"
- label="修改时间"
- width="220px"
- :show-overflow-tooltip="true"
- >
- </el-table-column>
- <el-table-column
- prop="xgr"
- label="修改人"
- width="160px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- prop="memo"
- label="备注"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
- :prop="scope.row.seq + '.memo'"
- :rules="tableFormRules.memo"
- >
- <el-input clearable
- style="width: 100%;"
- v-model="tableFormDataObj[scope.row.seq].memo"
- @keydown.native="keyDown" :id="scope.$index + scope.column.id"
- ></el-input>
- <template slot="error" slot-scope="scope">
- <p class="error" :title="scope.error">{{ scope.error }}</p>
- </template>
- </el-form-item>
- <span v-else>{{scope.row.memo}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="id"
- label="ID"
- width="140px"
- v-if="filterForm.data.show"
- ></el-table-column>
- </el-table>
- </el-form>
- <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="年计划编制-建材厂(水渣)新增"
- :visible.sync="dialog.editorBox.show"
- width="600px"
- :close-on-click-modal="false"
- :show-close="!loading"
- >
- <div>
- <el-form
- :model="dialog.editorBox.form.data"
- ref="dialog_form"
- size="mini"
- label-width="95px"
- :rules="dialog.editorBox.form.rules"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="产品名称"
- prop="productid"
- >
- <el-select
- placeholder=""
- prop="productid"
- v-model="dialog.editorBox.form.data.productid"
- style="width: 100%;"
- :rules="dialog.editorBox.form.productid"
- >
- <el-option
- v-for="item in nameObj.workprocid.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="yearmonth"
- >
- <zj-timegran-date
- v-model="dialog.editorBox.form.data.yearmonth"
- style="width: 100%;"
- :timegranId="'MONTH'"
- :defaultOffset="-1"
- :rules="dialog.editorBox.form.yearmonth"
- ></zj-timegran-date>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="计划量"
- prop="weight"
- >
- <el-input
- clearable
- v-model="dialog.editorBox.form.data.weight"
- style="width: 100%;"
- :rules="dialog.editorBox.form.weight"
- >
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="备注"
- prop="memo"
- >
- <el-input
- clearable
- v-model="dialog.editorBox.form.data.memo"
- style="width: 100%;"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <span
- slot="footer"
- class="dialog-footer"
- >
- <el-button
- :loading="loading"
- @click="dialog.editorBox.show = false"
- >取 消</el-button>
- <el-button
- type="primary"
- @click="dataSave"
- :loading="loading"
- >保 存</el-button>
- </span>
- </el-dialog>
- <el-dialog
- title="年计划编制-建材(水渣)复制"
- :visible.sync="dialog.editorBox2.show"
- width="400px"
- :close-on-click-modal="false"
- :show-close="!loading"
- >
- <div>
- <el-form
- :model="dialog.editorBox2.form.data"
- ref="dialog_form2"
- size="mini"
- label-width="300px"
- :rules="dialog.editorBox2.form.rules"
- >
- <el-row>
- <el-col>
- <el-col :span="12">
- <el-form-item
- label="月份"
- prop="yearmonth"
- label-width="100px"
- >
- <zj-timegran-date
- v-model="dialog.editorBox2.form.data.yearmonth"
- style="width: 150%;"
- :timegranId="'MONTH'"
- :rules="dialog.editorBox2.form.yearmonth"
- ></zj-timegran-date>
- </el-form-item>
- </el-col>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <span
- slot="footer"
- class="dialog-footer"
- >
- <el-button
- :loading="loading"
- @click="dialog.editorBox2.show = false"
- >取 消</el-button>
- <el-button
- type="primary"
- @click="but_copy_plural"
- :loading="loading"
- >保 存</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { zCheckNumber1 } from '@/utils/validator.js'
- import timegranDate from '@/components/zg/timegranDate.vue'
- import {formatDate, commonSummaries, getCookie} from '@/utils/util.js';
- export default {
- name: 'outElectricity',
- components: {
- 'zj-timegran-date': timegranDate
- },
- data () {
- let setDate = new Date();
- setDate.setDate(15);
- setDate.setMonth((setDate.getMonth() - 1));
- return {
- rowIndex: '',
- columnId: '',
- focusTarget: null,
- seqArr: [],
- editSetFlag: '',
- isCheck: false, // 是否为审核人
- filterForm: {
- show: true,
- data: {
- clock: '',
- clockc: '',
- workprocid: [],
- location: [],
- networkid: [],
- state: '',
- itemname: '',
- searchtype: '0',
- measureid: '',
- line: 'AT2014',
- unit: '',
- yearmonth: '',
- weight: '',
- cjr: '',
- xgr: '',
- xgsj: '',
- memo: '',
- cp: '',
- prproductid: '',
- sysl: '',
- wxsy: '',
- parentid: 'JCW',
- cjsj: '',
- jzsj: '',
- zt: '',
- show: false
- },
- rules: {
- },
- disabled: {
- networkid: false
- }
- },
- pageNum: 1,
- pageSize: 100,
- total: 0,
- singleTableHeight: 100,
- tableData: [
- ],
- loading: false,
- tableLoading: false,
- multipleSelection: [],
- tableFormDataObj: {},
- tableFormRules: {
- mintvalue: [
- // { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- mendvalue: [
- // { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- weight: [
- { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- wxsy: [
- { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- sysl: [
- { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- productid: [
- { required: true, message: '该项不能为空', trigger: 'change' }
- ],
- wastage: [
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- secondVal: [
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- memo: [
- ]
- },
- nameObj: {
- state: {
- obj: {
- '0': {
- name: '未编辑',
- color: '#7a7a7a'
- },
- '1': {
- name: '已编辑',
- color: 'rgb(28, 111, 217)'
- },
- '2': {
- name: '已审核',
- color: 'red'
- },
- '3': {
- name: '已接收',
- color: 'red'
- }
- },
- arr: [
- {
- id: '0',
- name: '未编辑'
- },
- {
- id: '1',
- name: '已编辑'
- },
- {
- id: '2',
- name: '已审核'
- },
- {
- name: '已接收',
- color: 'red'
- }
- ]
- },
- type: {
- obj: {
- '0': '否',
- '1': '是'
- },
- arr: [
- {
- id: '0',
- name: '否'
- },
- {
- id: '1',
- name: '是'
- }
- ]
- },
- unitid: {
- obj: {},
- arr: []
- },
- workprocid: {
- obj: {
- 'AT2014': {
- id: 'AT2014',
- name: '矿渣粉'
- }},
- arr: [{
- id: 'AT2014',
- name: '矿渣粉'
- }]
- },
- location: {
- obj: {},
- arr: [],
- showDataArr: []
- },
- locateid: {
- obj: {},
- arr: []
- },
- networkid: {
- obj: {},
- arr: []
- },
- userId: {
- obj: {},
- arr: []
- }
- },
- dialog: {
- fRow: null,
- editorBox: {
- show: false,
- type: '',
- form: {
- default: {
- workprocid: ''
- },
- data: {
- unitid: '',
- line: 'AT2014',
- yearmonth: '',
- weight: '',
- memo: '',
- sysl: '',
- wxsy: '',
- productid: ''
- },
- rules: {
- weight: [
- { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- workprocid: [{ required: true, message: '该项不能为空', trigger: 'change' }],
- yearmonth: [{ required: true, message: '该项不能为空', trigger: 'change' }],
- unitid: [{ required: true, message: '该项不能为空', trigger: 'change' }],
- line: [{ required: true, message: '该项不能为空', trigger: 'change' }],
- productid: [{ required: true, message: '该项不能为空', trigger: 'change' }],
- sysl: [
- { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- wxsy: [
- { required: true, message: '该项不能为空', trigger: 'change' },
- { validator: zCheckNumber1, trigger: 'change' }
- ]
- }
- }
- },
- editorBox2: {
- show: false,
- type: '',
- form: {
- data: {
- yearmonth: ''
- },
- rules: {
- yearmonth: [{ required: true, message: '该项不能为空', trigger: 'change' }]
- }
- }
- }
- },
- butPrivilege: {
- QUERY: false,
- PUT: false,
- CHECK: false,
- UNDOCHECK: false
- },
- loginName: getCookie('loginName')
- }
- },
- created () {
- // 获取按钮权限
- this.activeMenu = window.localStorage.getItem('activeMenu');
- for (let key in this.butPrivilege) {
- this.butPrivilege[key] = this.checkPrivilege(this.activeMenu + key);
- }
- },
- 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);
- });
- // 接收路由参数
- if (that.$route.query.networkid) {
- that.filterForm.disabled.networkid = true;
- that.filterForm.data.networkid = that.$route.query.networkid.split(',');
- }
- // 当有审核与取消审核权限时,默认其为审核人,审核人无法修改数据
- if (that.butPrivilege.CHECK || that.butPrivilege.UNDOCHECK) {
- that.isCheck = true;
- }
- // 管理员在这里录入数据
- if (that.loginName === 'admin' && that.filterForm.disabled.networkid) {
- that.isCheck = false;
- }
- // that.getLocation();
- that.getLocateIdData();
- that.getNetworkIdData();
- // that.getTableData();
- that.getUnitIdData();
- },
- methods: {
- // 计算树区域高度
- getRoleHeight (dom) {
- return window.innerHeight - dom.offsetTop;
- },
- // 自定义的表格合计方法:只给指定列进行合计
- getSummaries (param) {
- const prop = ['apportvalue', 'realvalue', 'wastage', 'weight']; // 合计列绑定的prop
- return commonSummaries(param, prop);
- },
- // 获取工序列表
- // getNodeData () {
- // let that = this
- // let url = 'pass/ems/v1/trmworkprocs/getIdAndName?issettle=1';
- // 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.workprocid.arr = arr;
- // that.nameObj.workprocid.obj = obj;
- // that.connn();
- // } else {
- // that.$message.error(res.message);
- // }
- // });
- // },
- getUnitIdData () {
- let that = this
- let url = 'pass/ems/v1/trmunits/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;
- if (item.name === '吨') {
- that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
- }
- }
- that.nameObj.unitid.arr = arr;
- that.nameObj.unitid.obj = obj;
- } else {
- that.$message.error(res.message);
- }
- });
- },
- // 获取站所
- getNetworkIdData () {
- let that = this
- let url = 'pass/ems/v1/trmstations/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.networkid.arr = arr;
- that.nameObj.networkid.obj = obj;
- } else {
- that.$message.error(res.message);
- }
- });
- },
- but_copy_plural () {
- let that = this;
- let SubmitData = [];
- for (let key in that.tableFormDataObj) {
- SubmitData.push({
- weight: that.tableFormDataObj[key].weight,
- cjr: that.tableFormDataObj[key].cjr,
- memo: that.tableFormDataObj[key].memo,
- line: that.tableFormDataObj[key].line,
- unit: that.tableFormDataObj[key].unit,
- parentid: that.filterForm.data.parentid,
- yearmonth: that.dialog.editorBox2.form.data.yearmonth,
- wxsy: that.tableFormDataObj[key].wxsy,
- sysl: that.tableFormDataObj[key].wxsy,
- productid: that.tableFormDataObj[key].productid
- });
- }
- that.$refs['dialog_form2'].validate((valid) => {
- if (valid) {
- that.loading = true;
- that.axios.post('pass/ems/v1/emsprodplanyears/', SubmitData, {
- contentType: 'application/json'
- })
- .then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: '复制成功',
- type: 'success'
- });
- that.getTableData();
- that.dialog.editorBox2.show = false;
- } else {
- that.$message.error(res.message);
- }
- that.loading = false;
- }).catch(function () {
- that.loading = false;
- });
- } else {
- this.$message.error('至少选择一条数据');
- }
- });
- },
- connn () {
- let that = this;
- if (!that.filterForm.data.networkid || that.filterForm.data.networkid.length === 0) {
- that.nameObj.location.showDataArr = that.nameObj.workprocid.arr;
- } else {
- let url = 'pass/ems/v1/trmelectricitylocations/getWorkprocs?workshop=' + that.filterForm.data.networkid.toString();
- that.axios.get(url)
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- for (let item of res.data) {
- arr.push({
- id: item.id,
- name: item.name
- })
- }
- that.nameObj.location.showDataArr = arr;
- } else {
- that.$message.error(res.message);
- }
- });
- }
- },
- // 获取位置
- getLocateIdData () {
- let that = this
- let url = 'pass/ems/v1/trmlocations/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.locateid.arr = arr;
- that.nameObj.locateid.obj = obj;
- } else {
- that.$message.error(res.message);
- }
- });
- },
- // 获取表格中的数据
- getTableData (pageNum) {
- let that = this,
- params = {},
- pData = {
- yearmonth: that.filterForm.data.yearmonth,
- workprocid: that.filterForm.data.workprocid.toString(),
- location: that.filterForm.data.location.toString(),
- networkid: that.filterForm.data.networkid.toString(),
- itemname: that.filterForm.data.itemname,
- zt: that.filterForm.data.zt,
- measureid: that.filterForm.data.measureid,
- exactsearch: that.filterForm.data.searchtype,
- parentid: that.filterForm.data.parentid
- };
- for (let key in pData) {
- if (pData[key]) {
- params[key] = pData[key];
- }
- }
- that.pageNum = pageNum || that.pageNum;
- that.tableLoading = true;
- // let url = 'pass/ems/v1/trmtransfereactvalues/getDateEditForPage/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
- // if (that.isCheck) {
- // url = 'pass/ems/v1/trmtransfereactvalues/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
- // }
- let url = 'pass/ems/v1/emsprodplanyears/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
- that.axios.get(url, {
- params: params
- })
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- for (let i = 0; i < res.data.list.length; i++) {
- let item = res.data.list[i];
- arr.push({
- seq: i,
- unit: item.unit,
- line: item.line,
- yearmonth: item.yearmonth,
- weight: item.weight,
- cjr: item.cjr,
- cjsj: item.cjsj,
- jzsj: item.jzsj,
- xgr: item.xgr,
- xgsj: item.xgsj,
- cp: item.cp,
- sysl: item.sysl,
- wxsy: item.wxsy,
- zt: item.zt,
- parentid: item.parentid,
- no: item.no,
- id: item.id,
- memo: item.memo,
- productid: item.productid
- });
- }
- that.total = res.data.total;
- that.tableData = arr;
- that.getAdds();
- } else {
- that.$message.error(res.message);
- }
- that.$nextTick(() => {
- setTimeout(() => {
- that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
- }, 1);
- });
- that.tableLoading = false;
- }).catch(function () {
- that.tableLoading = false;
- });
- },
- // 获取表格中的数据
- getTableDataEdit () {
- let that = this,
- params = {},
- pData = {
- yearmonth: that.filterForm.data.yearmonth,
- workprocid: that.filterForm.data.workprocid.toString(),
- location: that.filterForm.data.location.toString(),
- networkid: that.filterForm.data.networkid.toString(),
- itemname: that.filterForm.data.itemname,
- exactsearch: that.filterForm.data.searchtype,
- parentid: that.filterForm.data.parentid
- };
- for (let key in pData) {
- if (pData[key]) {
- params[key] = pData[key];
- }
- }
- that.tableLoading = true;
- let url = 'pass/ems/v1/emsprodplanyears/getDateEditForPage/?pageNum=1&pageSize=' + that.pageSize;
- that.axios.get(url, {
- params: params
- })
- .then(function (res) {
- if (res.code === '0') {
- let arr = [];
- for (let i = 0; i < res.data.list.length; i++) {
- let item = res.data.list[i];
- arr.push({
- seq: i,
- unit: item.unit,
- line: item.line,
- yearmonth: item.yearmonth,
- weight: item.weight,
- cjr: item.cjr,
- cjsj: item.cjsj,
- jzsj: item.jzsj,
- xgr: item.xgr,
- xgsj: item.xgsj,
- cp: item.cp,
- sysl: item.sysl,
- zt: item.zt,
- wxsy: item.wxsy
- });
- }
- that.total = res.data.total;
- that.tableData = arr;
- that.getAdds();
- } else {
- that.$message.error(res.message);
- }
- that.$nextTick(() => {
- setTimeout(() => {
- that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
- }, 1);
- });
- that.tableLoading = false;
- }).catch(function () {
- that.tableLoading = false;
- });
- },
- // 合并相同的用电地点
- arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
- let that = this;
- let tableData = this.$refs.singleTable.tableData
- let c1 = row.workprocid;
- let c2 = row.location;
- let c3 = row.workshop;
- let c4 = row.clock;
- let c5 = row.clocke;
- let rowsPan = 1;
- // let adds = this.$refs.singleTable.tableData[rowIndex].realvalue;
- if (column['property'] === 'workprocid' || column['property'] === 'adds') {
- if (rowIndex > 0 && c1 === tableData[rowIndex - 1].workprocid && c2 === tableData[rowIndex - 1].location &&
- c3 === tableData[rowIndex - 1].workshop && c4 === tableData[rowIndex - 1].clock && c5 === tableData[rowIndex - 1].clocke) {
- return {
- rowspan: 0,
- colspan: 0
- };
- };
- while (tableData[rowIndex + rowsPan] && c1 === tableData[rowIndex + rowsPan].workprocid && c2 === tableData[rowIndex + rowsPan].location &&
- c3 === tableData[rowIndex + rowsPan].workshop && c4 === tableData[rowIndex + rowsPan].clock && c5 === tableData[rowIndex + rowsPan].clocke) {
- rowsPan += 1
- }
- return {
- rowspan: rowsPan,
- colspan: 1
- };
- }
- },
- // 改变表格显示条数
- 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.disabled || !that.filterForm.disabled[key]) {
- if (that.filterForm.data[key] instanceof Array) {
- that.filterForm.data[key] = [];
- } else {
- that.filterForm.data[key] = '';
- }
- }
- }
- that.getTableData(1);
- },
- keyDown (event1, disabledFlag) {
- let tdTarget = event1.target;
- let _this = this;
- while (tdTarget.tagName !== 'TD') {
- tdTarget = tdTarget.parentElement;
- }
- // 如果按下键盘下键或者回车键
- if (event.keyCode === 40 || event.keyCode === 13) {
- let index = parseInt(this.rowIndex);
- // index++;
- if (index !== this.seqArr[this.seqArr.length - 1]) {
- for (let i = 0; i < this.seqArr.length; i++) {
- if (index === this.seqArr[i]) {
- index = this.seqArr[i + 1];
- break;
- }
- }
- }
- this.editSetFlag = index + this.columnId;
- let id = '#' + this.editSetFlag;
- this.$nextTick(() => {
- $(id).click();
- });
- } else if (event.keyCode === 38) { // 键盘上键
- let index = parseInt(this.rowIndex);
- if (index !== this.seqArr[0]) {
- for (let i = 0; i < this.seqArr.length; i++) {
- if (index === this.seqArr[i]) {
- index = this.seqArr[i - 1];
- break;
- }
- }
- }
- this.editSetFlag = index + this.columnId;
- let id = '#' + this.editSetFlag;
- this.$nextTick(() => {
- $(id).click();
- });
- } else if (event.keyCode === 37) { // 键盘左键
- $(tdTarget).prevAll().find('input:text').last().click();
- } else if (event.keyCode === 39) { // 键盘右键
- $(tdTarget).nextAll().find('input').eq(0).click();
- }
- },
- // 只允许对未接受的数据进行操作
- checkboxT (row, index) {
- if (row.zt === '2' && !this.isCheck) {
- return false;
- } else {
- return true;
- }
- },
- handleSelectionChange (val) {
- let that = this;
- let tableFormDataObj = {};
- let arr = [];
- for (let item of val) {
- arr.push(item.seq);
- }
- this.seqArr = arr.sort(sortNumber);
- for (let item of that.tableData) {
- item.isSelection = false;
- }
- for (let item of val) {
- let obj = {};
- let xId = item.seq;
- if (that.tableFormDataObj[xId]) {
- // 如果已存在该数据则使用该数据
- tableFormDataObj[xId] = that.tableFormDataObj[xId];
- } else {
- // 负责则从对应行中获取行内原数据
- for (let key in item) {
- obj[key] = item[key];
- }
- item.realvalue = (!isNaN(Number(item.apportvalue)) && !isNaN(Number(item.wastage))) ? Number(item.apportvalue) + Number(item.wastage) - Number(item.secondVal) : item.realvalue;
- tableFormDataObj[xId] = obj;
- }
- item.isSelection = true;
- }
- for (let item of that.tableData) {
- if (item.isSelection === false) {
- item.realvalue = (!isNaN(Number(item.apportvalue)) && !isNaN(Number(item.wastage))) ? Number(item.apportvalue) + Number(item.wastage) - Number(item.secondVal) : item.realvalue;
- }
- }
- that.tableFormDataObj = tableFormDataObj;
- that.multipleSelection = val;
- this.getAdds();
- },
- // 当上月底码发生改变时计算抄度与实际电量
- getApportValue (seq, value, rowIndex, event) {
- let that = this;
- if (!isNaN(Number(value))) {
- if (!isNaN(Number(that.tableFormDataObj[seq].mintvalue)) && !isNaN(Number(that.tableFormDataObj[seq].mendvalue)) && that.tableFormDataObj[seq].mintvalue !== null && that.tableFormDataObj[seq].mendvalue !== null) {
- let poor = that.floatComputed(Number(that.tableFormDataObj[seq].mendvalue), Number(that.tableFormDataObj[seq].mintvalue), '-');
- that.tableFormDataObj[seq].apportvalue = that.floatComputed(poor, Number(that.tableFormDataObj[seq].mods), '*').toFixed(0);
- let rv1 = that.floatComputed(Number(that.tableFormDataObj[seq].apportvalue), Number(that.tableFormDataObj[seq].wastage), '+');
- that.tableFormDataObj[seq].realvalue = that.floatComputed(rv1, Number(that.tableFormDataObj[seq].secondVal), '-').toFixed(0);
- that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
- }
- }
- },
- // 手动修改抄度后计算实际电量
- chnageApportvalue (seq, value, rowIndex) {
- let that = this;
- if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].wastage))) {
- that.tableFormDataObj[seq].realvalue = that.floatComputed(Number(value), Number(that.tableFormDataObj[seq].wastage), '+').toFixed(0);
- }
- that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
- },
- // 手动修改损耗后计算实际电量
- chnageWastage (seq, value, rowIndex) {
- let that = this;
- if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].apportvalue)) && that.tableFormDataObj[seq].apportvalue !== null) {
- let rv1 = that.floatComputed(Number(value), Number(that.tableFormDataObj[seq].apportvalue), '+');
- that.tableFormDataObj[seq].realvalue = that.floatComputed(rv1, Number(that.tableFormDataObj[seq].secondVal), '-').toFixed(0);
- that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
- }
- },
- // 手动修改二次转供电后计算实际电量
- chnageSecondVal (seq, value, rowIndex) {
- let that = this;
- if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].apportvalue)) && that.tableFormDataObj[seq].apportvalue !== null) {
- let val1 = that.floatComputed(Number(that.tableFormDataObj[seq].apportvalue), Number(that.tableFormDataObj[seq].wastage), '+');
- that.tableFormDataObj[seq].realvalue = that.floatComputed(val1, Number(value), '-').toFixed(0);
- that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
- }
- },
- // 统计合计值
- getAdds () {
- let that = this;
- let wlarr = [];
- for (var i = 0; i < that.tableData.length; i++) {
- wlarr.push(that.tableData[i].workprocid + '-' + that.tableData[i].location + '-' + that.tableData[i].workshop + '-' + that.tableData[i].clock + '-' + that.tableData[i].clocke);
- }
- let wls = [...new Set(wlarr)]
- let arrs = [];
- for (let wl of wls) {
- let adds = 0;
- for (let item of that.tableData) {
- if (wl === item.workprocid + '-' + item.location + '-' + item.workshop + '-' + item.clock + '-' + item.clocke) {
- adds = that.floatComputed(Number(item.realvalue), adds, '+');
- }
- }
- for (let i = 0; i < that.tableData.length; i++) {
- if (wl === that.tableData[i].workprocid + '-' + that.tableData[i].location + '-' + that.tableData[i].workshop + '-' + that.tableData[i].clock + '-' + that.tableData[i].clocke) {
- that.tableData[i].adds = adds;
- }
- }
- }
- },
- // 展示实际电量
- showRealValue (rowIndex, value) {
- let that = this;
- for (let i = 0; i < that.tableData.length; i++) {
- if (i === rowIndex) {
- that.tableData[i].realvalue = value;
- }
- }
- this.getAdds();
- },
- // 批量修改
- but_edit_plural () {
- let that = this;
- if (that.multipleSelection.length > 0) {
- that.$refs['dialog_form_arr'].validate((valid, obj) => {
- if (valid) {
- let SubmitData = [];
- for (let key in that.tableFormDataObj) {
- SubmitData.push({
- no: that.tableFormDataObj[key].no,
- weight: that.tableFormDataObj[key].weight,
- cjr: that.tableFormDataObj[key].cjr,
- memo: that.tableFormDataObj[key].memo,
- cjsj: that.tableFormDataObj[key].cjsj,
- jzsj: that.tableFormDataObj[key].jzsj,
- productid: that.tableFormDataObj[key].productid,
- xgr: that.tableFormDataObj[key].xgr,
- xgsj: that.tableFormDataObj[key].xgsj,
- cp: that.tableFormDataObj[key].cp,
- sysl: that.tableFormDataObj[key].sysl,
- zt: that.tableFormDataObj[key].zt,
- wxsy: that.tableFormDataObj[key].wxsy,
- unit: that.tableFormDataObj[key].unit,
- parentid: that.filterForm.data.parentid,
- yearmonth: that.tableFormDataObj[key].yearmonth
- });
- }
- that.loading = true;
- that.axios.put('pass/ems/v1/emsprodplanyears/batchupdate', 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;
- });
- }
- });
- } else {
- this.$message.error('至少选择一条数据');
- }
- },
- dataSave () {
- let that = this;
- let SubmitData = [];
- SubmitData.push({
- yearmonth: that.dialog.editorBox.form.data.yearmonth,
- weight: that.dialog.editorBox.form.data.weight,
- unit: that.dialog.editorBox.form.data.unitid,
- parentid: that.filterForm.data.parentid,
- memo: that.dialog.editorBox.form.data.memo,
- sysl: that.dialog.editorBox.form.data.sysl,
- wxsy: that.dialog.editorBox.form.data.wxsy,
- productid: that.dialog.editorBox.form.data.productid
- });
- that.$refs['dialog_form'].validate((valid) => {
- if (valid) {
- that.loading = true;
- that.axios.post('pass/ems/v1/emsprodplanyears/', SubmitData, {
- contentType: 'application/json'
- })
- .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;
- });
- }
- }
- );
- },
- // 批量删除
- but_del_plural () {
- let that = this;
- if (that.multipleSelection.length > 0) {
- let SubmitData = [];
- for (let item of that.multipleSelection) {
- if (item.zt === '2') {
- this.$message.error('已经审核的数据不能删除');
- return;
- }
- SubmitData.push({
- no: item.no
- });
- }
- that.$confirm('是否删除已选数据?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- state: 'warning'
- }).then(() => {
- that.axios.delete('pass/ems/v1/emsprodplanyears/delete', {
- data: SubmitData,
- contentType: 'application/json;charset=UTF-8'
- })
- .then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: '删除成功',
- type: 'success'
- });
- that.getTableData();
- } else {
- that.$message.error(res.message);
- }
- }).catch(function () {
- });
- }).catch(() => {
- });
- } else {
- this.$message.error('至少要选择一条数据');
- }
- },
- upState (state = '2') {
- let that = this;
- let dataArr = [];
- for (let item of that.multipleSelection) {
- if (item.state !== state) {
- dataArr.push(item);
- }
- }
- if (dataArr.length > 0) {
- that.$confirm('本次将要' + (state === '2' ? '审核' : '撤销审核') + dataArr.length + '条数据,是否确定?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- state: 'warning'
- }).then(() => {
- let SubmitData = [];
- for (let item of dataArr) {
- SubmitData.push({
- state: state,
- id: item.id
- });
- }
- that.loading = true;
- that.axios.put('pass/ems/v1/trmtransfereactvalues/batchcheck2', SubmitData)
- .then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: (state === '2' ? '审核' : '撤销') + '成功',
- type: 'success'
- });
- that.getTableData();
- } else {
- that.$message.error(res.message);
- }
- that.loading = false;
- }).catch(function () {
- that.loading = false;
- });
- }).catch(() => {
- });
- } else {
- if (that.multipleSelection.length > 0) {
- this.$message.error('没有需要' + (state === '2' ? '审核' : '撤销') + '的数据');
- } else {
- this.$message.error('至少要选择一条数据');
- }
- }
- },
- but_add () {
- let that = this;
- that.dialog.editorBox.show = true;
- setTimeout(() => {
- that.$refs['dialog_form'].clearValidate();
- }, 100);
- },
- but_copy () {
- let that = this;
- if (that.multipleSelection.length > 0) {
- that.dialog.editorBox2.show = true;
- setTimeout(() => {
- that.$refs['dialog_form2'].clearValidate();
- }, 100);
- } else {
- this.$message.error('至少要选择一条数据');
- }
- },
- tableRowClassName ({row, rowIndex}) {
- // 把每一行的索引放进row
- row.index = rowIndex;
- },
- cellClick (row, column, cell, event) {
- let _this = this;
- this.rowIndex = row.index;
- this.columnId = column.id;
- _this.editSetFlag = row.index + column.id;
- _this.focusTarget = event.target;
- while (_this.focusTarget.tagName !== 'TD') {
- _this.focusTarget = _this.focusTarget.parentElement;
- }
- _this.$nextTick(() => {
- let target = this.focusTarget;
- $(target).find('input').focus();
- });
- }
- }
- }
- function sortNumber (a, b) {
- return a - b
- }
- </script>
- <style lang="less">
- .outElectricity{
- 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;
- }
- }
- .rowDisable td {
- color: #6bb025 !important;
- }
- .el-table .el-table__row {
- height: 35px;
- }
- .el-table__body .el-form-item--mini.el-form-item {
- margin: 0px;
- .error {
- overflow: hidden;
- color: #f56c6c;
- font-size: 12px;
- line-height: 1;
- }
- }
- }
- .color_no {
- color: #7a7a7a;
- }
- .color_yes {
- color: #1a9f17;
- }
- .cnspicuous .el-checkbox__input.is-disabled .el-checkbox__inner {
- background-color: #dcdfe6;
- border-color: #babbbf;
- }
- }
- </style>
|