123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- <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.barname }}</span>
- </template>
- </el-table-column>
- <el-table-column :key="2" label="推料车名称" min-width="70px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.softccount }}</span>
- </template>
- </el-table-column>
- <el-table-column :key="3" label="推料车编号" min-width="90px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.ccount }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.ccount" step="0.01" type="number" style="width:95%;padding:10px 0;" />
- </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.ratio }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.ratio" step="0.01" type="number" style="width:95%;padding:10px 0;" />
- </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.ccountratio }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.ccountratio" type="number" style="width:95%;padding:10px 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)" />
- </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="handleCreate">确认</el-button>
- </div>
- </div>
- </el-dialog>
-
-
- </div>
- </template>
- <script>
- import { GetDataByName, postJson, GetDataByNames, compareSort, ExecDataByConfig, failproccess, PostDataByName, formatNum, checkButtons } 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 {
- table: {
- getdataListParm: {
- name: 'getFPList',
- page: 1,
- offset: 1,
- // pagecount: parseInt(Cookies.get('pageCount')),
- pagecount: '',
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- enable: '',
- barid: '',
- tname: ''
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- temp: {},
-
-
- },
- timevalue1: new Date(2016, 9, 10, 18, 40),
- timetags1: ['8:40','9:00','10:00'],
- dialogFull: false,
- isRoleEdit: [],
- headerList: [],
- pickerMinDate: '',
-
- tnameList: [], // 配方名 称
- recipeTemplateList: [], // 配方模板
- feedingFormulaList: [], // 补料配方
- livestockTypeList: [], // 类别
- barList: [],
- rules: {
- cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- },
-
- selectList: [],
-
-
- textMap: {
- Nutritional: '营养评估',
- history: '历史记录'
- },
- focusWRow: {}, // 一班重量得到焦点暂存
- focusWRow2: {}, // 2班重量得到焦点暂存
- focusWRow3: {}, // 3班重量得到焦点暂存
- focusWRow4: {}, // 4班重量得到焦点暂存
- 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:{},
- create1: {
- dialogFormVisible: false,
- dialogStatus: '',
- temp: { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '', sort: '' },
- 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' }]
- }
- },
- }
- },
- computed: {
-
-
- },
- created() {
- this.getButtons()
- this.getList()
-
- },
- methods: {
- getButtons() {
- const Edit = 'DhedFormula'
- const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
- this.isRoleEdit = isRoleEdit
- },
- getTimeList() {
- GetDataByName(this.getTimeListParm).then(response => {
- if (response.data.list !== null) {
- this.timeList = response.data.list
- } else {
- this.tnameList = []
- }
- })
- },
-
- // 新增
- handleCreate1() {
- console.log('点击了新增')
- this.resetTemp1()
- this.dialogFull = false
- this.create1.dialogStatus = 'create'
- this.create1.dialogFormVisible = true
- },
- resetTemp1() {
- this.create1.temp = { pastureid: Cookies.get('pastureid'), 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'sort': "", 'ftid': '', 'ftname': '', 'tmrcode': '', 'tmrid': '', 'times': '', 'lppcode': '', 'lppid': '', 'rtime': '', barid: '', 'treatmethod': '', 'useinbar': '', 'useinbarid': '' }
- },
-
-
- 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) // 编辑保存
- }
- // 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)
- })
- },
- handleSearch() {
- this.getList()
- },
- change_time1(e){
- console.log(e)
- },
- tag_close1(e){
- console.log(e)
- },
- 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
- row.ftid = String(row.ftid)
- if (row.ptsfid == '-1') {
- row.ptsfid = ''
- }
- row.ptsfid = String(row.ptsfid)
- // dryweight
- this.table.temp.ftid = row.ftid
- this.table.temp.ftname = row.ftname
- this.table.temp.ptsfid = row.ptsfid
- this.table.temp.ptsfname = row.ptsfname
- },
- updateData(row) {
-
- var arr = []
- for (let i = 1; i <= this.table.RWLength; i++) {
- var obj = {}
- obj['times'] = i
- obj['pastureid'] = row.pastureid
- obj['barid'] = row.barid
- obj['cowcount'] = row.ccount
- obj['ccountradio'] = row.ccountradio
- obj['ptid'] = row.ftid
- if (row.ptsfid !== '') {
- obj['ptsid'] = row.ptsfid
- } else {
- obj['ptsid'] = '-1'
- }
- obj['weight'] = row['w' + i]
- if(row['bw' + i] == ""){
- obj['supplement'] = 0
- }else{
- obj['supplement'] = row['bw' + i]
- }
- obj['tratio'] = Math.round(row['r' + i])
- obj['todaysupplement'] = row.todaysupplement
- obj['todayweight'] = row.todayweight
- arr.push(obj)
- }
- if (this.table.isPtsfname == 0) {
- row.ptsfid = '-1'
- row.ptsfname = ''
- } else {
- if (row.ptsfid == '') {
- row.ptsfid = '-1'
- row.ptsfname = ''
- }
- }
- if (row.supplyweight == '') {
- row.supplyweight = '0'
- }
- if (this.table.isPtsfname == false) {
- row.supplyweight = '0'
- }
- console.log(row, '============')
- this.$set(row, 'ratio', Math.floor(parseFloat(row.ratio) * 100) / 100)
- this.$set(row, 'ccountratio', Math.floor(parseFloat(row.ccountratio) * 100) / 100)
- row.ccountratio = String(row.ccountratio)
- row.sumr = Math.round(row.sumr)
- // for(let i=0;i<arr.length;i++){
- // if(arr[i].tratio == undefined ||arr[i].tratio =='' || arr[i].tratio == null){
- // arr[i].tratio = 0
- // }
- // }
- this.table.rwList = arr
- console.log('点击了编辑保存', row)
- this.table.temp.pastureid = row.pastureid
- this.table.temp.id = row.id
- this.table.temp.barname = row.barname
- this.table.temp.barid = row.barid
- this.table.temp.ccount = row.ccount
- this.table.temp.ratio = row.ratio
- this.table.temp.ccountratio = row.ccountratio
- this.table.temp.ftid = row.ftid
- this.table.temp.ftname = row.ftname
- this.table.temp.ptsfid = row.ptsfid
- this.table.temp.ptsfname = row.ptsfname
- this.table.temp.ftweight = row.ftweight
- this.table.temp.supplyweight = row.supplyweight
- this.table.temp.feedweight = row.feedweight
- this.table.temp.owner = row.owner
- this.table.temp.sumr = row.sumr
-
- console.log(row, '===========')
- this.table.temp.softccount = row.softccount
-
- var obj = {}
- obj.pastureid = row.pastureid
- obj.id = row.id
- obj.data = []
-
-
-
- if (this.table.temp.ccount === '') {
- 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)
- // this.requestParam.parammaps = this.table.temp
- this.requestParam.common = {
- 'returnmap': '0'
- }
- this.requestParam.data = []
- this.requestParam.data[0] = { 'name': 'updateBigFP', 'type': 'e', 'parammaps': {
- pastureid: row.pastureid,
- id: row.id,
- barname: row.barname,
- barid: row.barid,
- softccount: row.softccount,
- ccount: row.ccount,
- ratio: row.ratio,
- ccountratio: row.ccountratio,
- ftid: row.ftid,
- ftname: row.ftname,
- ptsfid: row.ptsfid,
- ptsfname: row.ptsfname,
- ftweight: row.ftweight,
- supplyweight: row.supplyweight,
- feedweight: row.feedweight,
- owner: row.owner,
- sumr: row.sumr
- }}
- this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table.rwList }}
- this.requestParam.data[1].children = []
- this.requestParam.data[1].children[0] = { 'name': 'updateBigFPDetail', 'type': 'e', 'parammaps': {
- pastureid: '@insertSpotList.pastureid',
- barname: row.barname,
- barid: '@insertSpotList.barid',
- times: '@insertSpotList.times',
- tratio: '@insertSpotList.tratio',
- weight: '@insertSpotList.weight',
- cowcount: '@insertSpotList.cowcount',
- ccountradio: row.ccountratio,
- ptid: '@insertSpotList.ptid',
- ptsid: '@insertSpotList.ptsid',
- supplement: '@insertSpotList.supplement',
- feedweight: row.feedweight,
- supplyweight: row.supplyweight,
- ratio: row.ratio
- }}
- this.requestParam.data[2] = { 'name': 'updateLPPbyFPChange', 'type': 'e', 'parammaps': {
- pastureid: row.pastureid,
- fpid: row.id
- }}
- ExecDataByConfig(this.requestParam).then(response => {
- console.log('编辑保存发送参数', this.requestParam)
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- if(obj.data.length>0){
- const url = 'authdata/fpdetail/edit'
- const data = obj
- postJson(url, data).then(response => {
- if(response.msg !== 'fail'){
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- }
- })
- }else{
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- }
- this.getList()
- 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')
- }
- }
- }
- })
- },
- 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 ''
- }
- },
-
-
-
-
-
-
- // 应用
- 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;
- }
- </style>
- <style lang="scss">
- .red-row{
- background: #fde2e2 !important;
- }
- </style>
|