1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012 |
- <template>
- <div class="app-container">
- <div class="operation">
-
- <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float: left;" @click="handleCreate1">设置推料时间</el-button>
- <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float: left;" @click="handleCreate2">设置允许误差时间</el-button>
-
- <el-button v-if="isRoleEdit" class="success" icon="el-icon-open" style="float: left;" @click="handleTakeEffect">启用</el-button>
- <el-button v-if="isRoleEdit" class="danger" icon="el-icon-turn-off" style="float: left;" @click="handleDisable">禁用</el-button>
- <el-button v-if="isRoleEdit" class="success" style="float: left;" @click="handleCheck">校验</el-button>
-
- </div>
-
- <div class="table">
- <el-table
- :key="table.tableKey"
- ref="table"
- v-loading="table.listLoading"
- element-loading-text="给我一点时间"
- :data="table.list"
- border
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- :max-height="myHeight"
- @header-click="headerClick"
- @cell-click="cellClick"
- @selection-change="handleSelect"
- @cell-dblclick="celldblclick"
- >
- <el-table-column type="selection" width="50" />
- <el-table-column :key="1" label="序号" align="center" type="index" width="50px" class-name="small-padding fixed-width" fixed="left" />
- <el-table-column label="栏舍名称" min-width="100px" align="center" class-name="small-padding fixed-width" fixed="left">
- <template slot-scope="scope">
-
- <span >{{ scope.row.bname }}</span>
-
- </template>
- </el-table-column>
- <el-table-column :key="2" label="推料车名称" min-width="70px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.tmrname }}</span>
- <el-select v-if="scope.row.Edit" v-model="scope.row.tmrid" filterable placeholder="推料车名称" class="filter-item" style="width:95%;padding:10px 0;" @change="changeTmrCode(scope.$index, scope.row, $event)">
- <el-option v-for="item in tmrCodeList" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column :key="3" label="推料车编号" min-width="90px" align="center">
- <template slot-scope="scope">
- <span >{{ scope.row.tmrcode }}</span>
-
- </template>
- </el-table-column>
- <el-table-column :key="4" label="推料时间(每天)" min-width="85px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.times }}</span>
-
- <el-tag v-if="scope.row.Edit" v-for="tag in scope.row.timesArr" :key="tag" closable @close="tag_close(scope.$index, scope.row, tag)" type="success">{{tag}}</el-tag>
-
- <el-time-picker v-if="scope.row.Edit"
- v-model="scope.row.times"
- :picker-options="{ selectableRange: '00:00:00 - 23:59:59' }"
- value-format="HH:mm"
- @change="change_time(scope.$index, scope.row, $event)" format="HH:mm"
- placeholder="任意时间点">
- </el-time-picker>
-
-
- </template>
- </el-table-column>
- <el-table-column :key="5" label="允许误差时间(分钟)" min-width="85px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.allowableerror }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.allowableerror" type="number" style="width:95%;padding:10px 0;" />
- </template>
- </el-table-column>
- <el-table-column label="是否启用" min-width="90px" align="center">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
- <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
- <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
- <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
- <el-button v-if="isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
- </template>
- </el-table-column>
- </el-table>
- <!-- <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" /> -->
- </div>
-
- <el-dialog :fullscreen="dialogFull" :visible.sync="create1.dialogFormVisible" :close-on-click-modal="false" width="50%">
- <template slot="title">
- <div class="avue-crud__dialog__header">
- <span class="el-dialog__title">
- <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
- 推料计划
- </span>
- <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
- <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
- <svg-icon v-else icon-class="fullscreen" />
- </div>
- </div>
- </template>
- <div class="app-add">
- <el-form ref="temp" :rules="create1.rules" :model="create1.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
-
- <el-row>
- <el-col :span="6">
- <el-form-item label="设置时间:" prop="useinbarid">
- <el-time-picker
- v-model="timevalue1"
- :picker-options="{ selectableRange: '00:00:00 - 23:59:59' }"
- value-format="HH:mm"
- @change="change_time1" format="HH:mm"
- placeholder="任意时间点">
- </el-time-picker>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-tag v-for="tag in timetags1" :key="tag.name" closable @close="tag_close1(tag)" type="success">{{tag}}</el-tag>
- </el-row>
-
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="create1.dialogFormVisible = false;getList()">关闭</el-button>
- <el-button class="save" @click="create_sure1">确认</el-button>
- </div>
- </div>
- </el-dialog>
- <el-dialog :fullscreen="dialogFull" :visible.sync="create2.dialogFormVisible" :close-on-click-modal="false" width="50%">
- <template slot="title">
- <div class="avue-crud__dialog__header">
- <span class="el-dialog__title">
- <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
- 允许误差时间
- </span>
- <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
- <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
- <svg-icon v-else icon-class="fullscreen" />
- </div>
- </div>
- </template>
- <div class="app-add">
- <el-form ref="temp" :rules="create2.rules" :model="create2.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
-
- <el-row>
- <el-col :span="12">
- <el-form-item label="允许误差时间(分钟):" prop="allowableerror">
- <el-input ref="time" v-model="create2.temp.allowableerror" class="filter-item" placeholder="请输入" type="text" />
- </el-form-item>
- </el-col>
- </el-row>
-
-
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="create2.dialogFormVisible = false;getList()">关闭</el-button>
- <el-button class="save" @click="create_sure2">确认</el-button>
- </div>
- </div>
- </el-dialog>
- <!-- 校验 -->
- <el-dialog title="提示" :destroy-on-close="true" :visible.sync="check.dialogFormVisible" :close-on-click-modal="false" width="30%">
- <div class="check">
- <p v-if="check.temp.isDistribution1 == '0'">未启用分配如下:</p>
- <p v-else>当前栏舍已分配完</p>
- {{ check.temp.banme1 }}
- <p v-if="check.temp.isDistribution2 == '0'">未启用栏舍如下:</p>
- <p v-else>当前栏舍已全部启用</p>
- {{ check.temp.banme2 }}
- </div>
- <div slot="footer" class="dialog-footer" style="bottom: 10px;">
- <el-button class="save" @click="check.dialogFormVisible=false;">确认</el-button>
- </div>
- </el-dialog>
-
-
-
- </div>
- </template>
- <script>
- import { GetDataByName, postJson, GetDataByNames, compareSort, ExecDataByConfig, failproccess, PostDataByName, formatNum, checkButtons, checkDates } from '@/api/common'
- import Pagination from '@/components/Pagination'
- import Pagination2 from '@/components/Pagination2'
- import { parseTime, json2excel, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
- import { MessageBox } from 'element-ui'
- import Cookies from 'js-cookie'
- import axios from 'axios'
- import { getToken } from '@/utils/auth'
-
- export default {
- inject: ['reload'],
- name: 'PushMaterialPlan',
- components: { Pagination, Pagination2 },
- data() {
- return {
- tmrCodeList:[
- // {Code: "001", id: 46, name: "一号推料车"},
- // {Code: "002", id: 47, name: "二号推料车"}
- ],
- table: {
- getdataListParm: {
- name: 'getPushingList',
- page: 1,
- offset: 1,
-
- pagecount: '',
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
-
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- temp: {},
-
-
- },
- create1: {
- dialogFormVisible: false,
- dialogStatus: '',
- temp: { pastureid: Cookies.get('pastureid'), fname: ''},
- rules: {
- // fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
- // fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
- // feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- }
- },
- create2: {
- dialogFormVisible: false,
- dialogStatus: '',
- temp: { pastureid: Cookies.get('pastureid'), allowableerror: ''},
- rules: {
- // fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
- // fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
- // feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- }
- },
- check: {
- dialogFormVisible: false,
- dialogStatus: '',
- getCheckParm: {
- name: 'checkRemainplan',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid')
- }
- },
- temp: {
- bnames: '',
- isDistribution1: '',
- isDistribution2: ''
- }
- },
- timevalue1: new Date(2022, 9, 10, 18, 40),
- timetags1: [],
- dialogFull: false,
- isRoleEdit: [],
- headerList: [],
- pickerMinDate: '',
-
-
- rules: {
- cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- },
-
- selectList: [],
-
-
-
- requestParam: {},
- download: {
- getdataListParm: {
- name: 'getFPList',
- page: 1,
- offset: 1,
- pagecount: 0,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- enable: ''
- }
- },
- list: []
- },
- spanObj: {},
- mergekeys: ['barname', 'sumweight'],
- isShowDialog: false,
- isokDisable: false,
- rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
- cellStyle: { padding: 0 + 'px' },
- myHeight: document.documentElement.clientHeight - 85 - 140,
- oldRowList:{},
-
- }
- },
- computed: {
-
-
- },
- created() {
- this.getButtons()
- this.getTMRlist()
- this.getList()
-
- },
- methods: {
- getButtons() {
- const Edit = 'DhedFormula'
- const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
- this.isRoleEdit = isRoleEdit
- },
- getTMRlist() {
- var send_data = {"name":"getPushingTmrList","page":1,"offset":1,"pagecount":"","returntype":"Map","parammaps":{"dictname":"推料车"}}
- GetDataByName(send_data).then(response => {
- if (response.data.list !== null) {
- this.tmrCodeList = response.data.list
- } else {
- this.tmrCodeList = []
- }
- console.log("tmrCodeList",this.tmrCodeList)
- })
- },
- getList() {
- this.table.listLoading = true
- GetDataByName(this.table.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- for (let i = 0; i < response.data.list.length; i++) {
- this.$set(response.data.list[i], 'Edit', false) // 编辑
- this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
- this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
- this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
-
- }
- response.data.list.forEach(function(item){
- if(item.times !== ""){
- item.timesArr = item.times.split(',')
- }else{
- item.timesArr = []
- }
- })
- // console.log(response.data.list, sumr)
-
- this.table.list = response.data.list
- console.log(this.table.list, 'this.table.list')
- this.table.pageNum = response.data.pageNum
- this.table.pageSize = response.data.pageSize
- this.table.total = response.data.total
- } else {
- this.table.list = []
- }
- setTimeout(() => {
- this.table.listLoading = false
- }, 100)
- })
- },
- // 推料车
- changeTmrCode(index,row,item) {
- console.log("推料车:====",index,row,item)
- var Code = this.tmrCodeList.find(obj => obj.id === row.tmrid).Code
- var itemName = this.tmrCodeList.find(obj => obj.id === row.tmrid).name
- console.log( "推料车编号:====",Code , itemName)
- this.table.list[index].tmrcode = Code
- this.table.list[index].tmrname = itemName
-
- },
-
-
- // 新增
- handleCreate1() {
- console.log('点击了新增')
- if (this.selectList.length == 0) {
- this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
- } else {
- this.resetTemp1()
- this.dialogFull = false
- this.create1.dialogStatus = 'create'
- this.create1.dialogFormVisible = true
- }
-
- },
- resetTemp1() {
- this.timetags1 = []
- },
-
- create_sure1(){
- console.log('timetags1-----',this.timetags1)
- console.log('selectList-----',this.selectList)
- var timeArrRea = this.timetags1
- var selectArr = this.selectList
- var idsArr = []
- selectArr.forEach(function(item){
- idsArr.push(item.id)
- })
- var timeIdArr = []
- idsArr.forEach(function(item){
- timeArrRea.forEach(function(items){
- timeIdArr.push({"time":items,"id":item})
- })
- })
- console.log("timeIdArr",timeIdArr)
- var send_data2 = {
- "common":{"returnmap":"0"},
- "data":[
- {
- "name":"delPushingDetailByIds",
- "type":"e",
- "parammaps":{"ids":idsArr.join(",")}
- },
- {
- "name":"insertPushingDetail",
- "resultmaps":{
- "list":timeIdArr
- },
- "children":[{"name":"insertPushingDetailByPushingId","type":"e","parammaps":
- {"pastureid":Cookies.get('pastureid'),"id":"@insertPushingDetail.id","time":"@insertPushingDetail.time","type":0}}]}
- ]}
-
- ExecDataByConfig(send_data2).then(response => {
- console.log('设置推料', send_data2)
- console.log('设置推料', response)
- if (response.msg === 'fail') {
- this.$notify({ title: '设置失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
-
- this.$notify({ title: '设置成功', message: '设置成功', type: 'success', duration: 2000 })
- this.create1.dialogFormVisible = false
- this.getList()
-
- }
- })
- },
- handleCreate2() {
-
- if (this.selectList.length == 0) {
- this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
- } else {
- console.log('点击了新增')
- this.resetTemp2()
- this.dialogFull = false
- this.create2.dialogStatus = 'create'
- this.create2.dialogFormVisible = true
- }
- },
- resetTemp2() {
- this.create2.temp = { pastureid: Cookies.get('pastureid'), 'allowableerror': '' }
- },
- create_sure2(){
- console.log(this.selectList)
- var allowableerror = this.create2.temp.allowableerror
- var selectArr = this.selectList
- var idsArr = []
- selectArr.forEach(function(item){
- idsArr.push(item.id)
- })
- var send_data = {"name":"updateAllowableerrorByIds","parammaps":{"allowableerror":allowableerror,"ids":idsArr.join(",")}}
- PostDataByName(send_data).then(response => {
- if (response.msg === 'fail') {
- this.$notify({ title: '设置失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
-
- this.$notify({ title: '设置成功', message: '设置成功', type: 'success', duration: 2000 })
- this.create2.dialogFormVisible = false
- this.getList()
-
- }
- })
- },
-
-
-
-
- change_time1(tag){
- console.log("tag", tag)
- console.log("timetags1", this.timetags1)
-
- this.timetags1.push(tag)
- },
- tag_close1(tag){
- console.log("tag", tag)
- console.log("timetags1", this.timetags1)
-
- this.timetags1.splice(this.timetags1.indexOf(tag), 1);
- },
-
- change_time(index,row,item){
- console.log("item", index,row,item)
- this.table.list[index].timesArr.push(item)
-
-
- },
- tag_close(index,row,tag){
- console.log("tag", index,row,tag)
- this.table.list[index].timesArr.splice(this.table.list[index].timesArr.indexOf(tag), 1);
-
- },
- // 校验
- handleCheck() {
- console.log('点击了校验')
- this.check.dialogStatus = 'check'
- this.check.dialogFormVisible = true
- this.getCheckList()
- },
- getCheckList() {
- var check_data = {"name":"checkPushingBar","offset":0,"pagecount":0,"parammaps":{"pastureid":Cookies.get('pastureid')}}
- GetDataByName(check_data).then(response => {
- console.log(response)
- if (response.data.list[0].banme1 !== undefined) {
- this.check.temp.isDistribution1 = 0
- this.check.temp.banme1 = response.data.list[0].banme1
- } else {
- this.check.temp.isDistribution1 = 1
- }
- if (response.data.list[0].banme2 !== undefined) {
- this.check.temp.isDistribution2 = 0
- this.check.temp.banme2 = response.data.list[0].banme2
- } else {
- this.check.temp.isDistribution2 = 1
- }
- })
- },
- handleTakeEffect() {
- console.log(this.selectList)
- if (this.selectList.length == 0) {
- this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
- } else {
- MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
- confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- var selectArr = this.selectList
- var idsArr = []
- selectArr.forEach(function(item){
- idsArr.push(item.id)
- })
- var send_data = {
- "name":"updateEnableByIds",
- "parammaps":{"enable":"1","ids":idsArr.join(",")}
- }
- GetDataByName(send_data).then(response => {
-
- if (response.msg == 'fail') {
- this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
- this.getList()
- }
-
- })
-
- })
- }
- },
- handleDisable() {
- if (this.selectList.length == 0) {
- this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
- } else {
- MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
- confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- var selectArr = this.selectList
- var idsArr = []
- selectArr.forEach(function(item){
- idsArr.push(item.id)
- })
- var send_data = {
- "name":"updateEnableByIds",
- "parammaps":{"enable":"0","ids":idsArr.join(",")}
- }
- GetDataByName(send_data).then(response => {
-
- if (response.msg == 'fail') {
- this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
- this.getList()
- }
-
- })
- })
- }
- },
- renderHeader(h, { column, $index }) { // h即为cerateElement的简写,具体可看vue官方文档
- return h(
- 'div',
- [
- h('span', column.label),
- h('i', {
- class: 'el-icon-unlock',
- ref: 'el-icon-unlock',
- style: 'margin-left:5px;'
- })
- ]
- )
- },
- headerClick(column, event) {
- console.log(column, event)
- this.headerList.push(event)
- for (let i = 0; i < this.table.list.length; i++) {
- if (this.table.list[i].Edit == true) {
- if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
- event.target.className = 'el-icon-lock'
- this.$set(this.table.list[i], 'isTwoWeight', true) // 锁住不可编辑
- } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
- event.target.className = 'el-icon-unlock'
- this.$set(this.table.list[i], 'isTwoWeight', false) // 解锁可编辑
- }
- }
- }
- },
-
-
-
-
-
-
- celldblclick(row, column, cell, event) {
- console.log(row, '=====')
- this.handleUpdate(row)
- },
- // 编辑
- handleUpdate(row) {
- console.log(row)
- this.oldRowList = {...row}
- for (let i = 0; i < this.table.list.length; i++) {
- if (this.table.list[i].Edit == true) {
- this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
- return false
- }
- }
- // 编辑true,不可编辑false
- row.Edit = true
- row.NoEdit = false
- // 编辑false,编辑保存true
- row.isUpdate = false
- row.isUpdateSave = true
-
- },
- updateData(row) {
-
-
- console.log('点击了编辑保存', row)
-
- row.pastureid = Cookies.get('pastureid')
-
-
- if (row.tmrname === '') {
- this.$message({ type: 'error', message: '推料车名称不能为空', duration: 2000 })
- return false
- }
-
- // const positiveInteger = /^[0-9]\d*$/
- // if (!positiveInteger.test(parseFloat(this.table.temp.ccount))) {
- // this.$message({
- // type: 'error',
- // message: '实际牛头数请输入正整数',
- // duration: 2000
- // })
- // return false
- // }
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- var timeArrRea = row.timesArr
- var timesTempArr = []
- timeArrRea.forEach(function(item){
- timesTempArr.push({"time":item})
- })
- var send_data = {
- "common":{"returnmap":"0"},
- "data":[
- {
- "name":"checkPushing","resultmaps":{"list":timesTempArr},
- "children":[
- {
- "name":"checkPushing","type":"v",
- "parammaps": {
- "tmrname":row.tmrname,
- "tmrid":row.tmrid,
- "id":row.id,
- "time":"@checkPushing.time",
- "type":0
- }
- }
- ]
- }
- ]
- }
-
- if(row.id == 0){
- var send_data2 = {
- "common":{"returnmap":"0"},
- "data":[
- {"name":"insertPushing","type":"e",
- "parammaps": row
- },
- {"name":"insertPushingDetail",
- "resultmaps":{
- "list":timesTempArr
- },
- "children":[
- {
- "name":"insertPushingDetail","type":"e","parammaps":
- {
- "pastureid":Cookies.get('pastureid'),
- "barid":row.barid,"time":"@insertPushingDetail.time","type":0}}]}
- ]}
- }else {
- var send_data2 = {
- "common":{"returnmap":"0"},
- "data":[
- {"name":"updatePushing","type":"e",
- "parammaps":row
- },
- {"name": "delPushingDetail","type": "e",
- "parammaps": {"id": row.id }
- },
- {"name":"insertPushingDetail",
- "resultmaps":{"list":timesTempArr},
- "children":[
- {"name":"insertPushingDetail","type":"e",
- "parammaps":
- {"pastureid":Cookies.get('pastureid'),
- "barid":row.barid,"time":"@insertPushingDetail.time","type":0}}]}
- ]}
- }
- checkDates(send_data).then(response => {
- console.log(response)
- if (response.data === ture) {
- ExecDataByConfig(send_data2).then(response => {
- console.log('编辑保存发送参数', send_data2)
- console.log('编辑保存', response)
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
-
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
-
- this.getList()
-
- }
- })
- } else {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
-
- }
- })
-
-
- },
- updateCancel(row) {
- console.log('点击了编辑取消')
- // 编辑false,不可编辑true
- row.Edit = false
- row.NoEdit = true
- // 编辑true,编辑保存false
- row.isUpdate = true
- row.isUpdateSave = false
- // this.reload()
- for (let i = 0; i < this.headerList.length; i++) {
- if (this.headerList[i].target.className == 'el-icon-lock') {
- this.headerList[i].target.className = 'el-icon-unlock'
- this.$set(this.headerList[i].target, 'className', 'el-icon-unlock')
- }
- }
- console.log(this.table.getdataListParm.offset)
- this.table.getdataListParm.offset = this.table.getdataListParm.offset
- this.getList()
- // this.$router.push('/formulationPlan/dhedFormula')
- },
- cellClick(row, column, event) {
- console.log(column)
- },
- handleSelect(val) {
- console.log('勾选数据', val)
- this.selectList = val
- },
-
- tableRowClassName({ row }) {
- // console.log(row)
- if (row.isColor == '0') {
- return 'red-row'
- } else {
- return ''
- }
- },
-
-
-
- // 删除
- handleRowDelete(row) {
- console.log('点击了行内删除')
- MessageBox.confirm('是否确认删除此信息?', {
- confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- this.selectList = []
- this.requestParam.name = 'deleteDungsieve'
- this.requestParam.parammaps = {}
- this.requestParam.parammaps.pastureid = row.pastureid
- this.requestParam.parammaps.id = row.id
- PostDataByName(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
- this.getList()
- }
- })
- }).catch(() => {
- this.$message({ type: 'info', message: '已取消删除' })
- })
- },
-
-
- // 应用
- handleApplication() {
- console.log('点击了应用')
- MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
- confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- this.requestParam.name = 'applyFPdate'
- this.requestParam.parammaps = {}
- this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
- this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
- PostDataByName(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
-
- this.getList()
- }
- })
- }).catch(() => {
- this.$message({ type: 'info', message: '已取消应用' })
- })
- },
-
-
- formatJson(filterVal, jsonData) {
- return jsonData.map(v =>
- filterVal.map(j => {
- if (j === 'timestamp') {
- return parseTime(v[j])
- } else {
- return v[j]
- }
- })
- )
- },
-
- blurBw(row) {
- console.log(row)
- },
- focusBw(row) {
- console.log(row)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .search {
- clear: both;
- }
- .table {
- margin-top: 10px;
- }
- .el-tag{margin-right: 5px;}
- </style>
- <style lang="scss">
- .red-row{
- background: #fde2e2 !important;
- }
- </style>
|