123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925 |
- <template>
- <div class="app-container">
- <el-tabs v-model="activeName" @tab-click="handleTabClick">
- <el-tab-pane label="体况、粪便评分标准" name="first">
- <div class="operation" style="position: relative;">
- <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
- <el-button class="import" style="float: right;">导入</el-button>
- </el-upload>
- <el-dropdown style="float: right;margin-right: 10px;">
- <el-button class="export">导出</el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
- <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <div class="table1">
- <el-table
- :key="table1.tableKey"
- v-loading="table1.listLoading"
- element-loading-text="给我一点时间"
- :data="table1.list"
- border
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="序号" align="center" type="index" width="50px" />
- <el-table-column label="配方名称" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.ftname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="体况评分标准" align="center" min-width="300px">
- <el-table-column label="体况评分标准(分)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bodystandard }}</span>
- </template>
- </el-table-column>
- <el-table-column label="数据来源" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bodysource }}</span>
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column label="粪便评分标准" align="center" min-width="300px">
- <el-table-column label="粪便评分标准(分)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.dungstandard }}</span>
- </template>
- </el-table-column>
- <el-table-column label="数据来源" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.dungsource }}</span>
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-tab-pane>
- <el-tab-pane label="宾州筛、粪便筛标准范围" name="second">
- <div class="operation">
- <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers2" :data="uploadData2" :action="uploadExcelUrl2" :show-file-list="false" :before-upload="beforeImport2" :on-success="handleImportSuccess2">
- <el-button class="import" style="float: right;">导入</el-button>
- </el-upload>
- <el-dropdown style="float: right;margin-right: 10px;">
- <el-button class="export">导出</el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item @click.native="handleExport(3)">导出模板</el-dropdown-item>
- <el-dropdown-item @click.native="handleExport(4)">导出数据</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <div class="table2">
- <el-table
- :key="table2.tableKey"
- v-loading="table2.listLoading"
- element-loading-text="给我一点时间"
- :data="table2.list"
- border
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="序号" align="center" type="index" width="50px" />
- <el-table-column label="牲畜类别" align="center" min-width="200px">
- <el-table-column label="牲畜父类" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.parentname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="牲畜子类" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.cowname }}</span>
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column label="宾州筛" align="center" min-width="200px">
- <el-table-column label="宾州筛一层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bzonemin }} - {{ scope.row.bzonemax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="宾州筛二层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bztwomin }} - {{ scope.row.bztwomax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="宾州筛三层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bzthreemin }} - {{ scope.row.bzthreemax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="宾州筛四层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bzfourmin }} - {{ scope.row.bzfourmax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="数据来源" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.bzsource }}</span>
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column label="粪便筛" align="center" min-width="300px">
- <el-table-column label="粪便筛一层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fbonemin }} - {{ scope.row.fbonemax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="粪便筛二层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fbtwomin }} - {{ scope.row.fbtwomax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="粪便筛三层(%)" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fbthreemin }} - {{ scope.row.fbthreemax }}</span>
- </template>
- </el-table-column>
- <el-table-column label="数据来源" min-width="80px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fbsource }}</span>
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-tab-pane>
- </el-tabs>
- <!-- 体况、粪便评分标准 -->
- <el-dialog :title="textMap[table1.dialogStatus]" :visible.sync="table1.dialogFormVisible" :close-on-click-modal="false" width="80%">
- <div class="app-add">
- <el-form ref="temp" :rules="table1.rules" :model="table1.temp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
- <el-row>
- <el-col :span="12">
- <h3 style="width: 160px;float: left;">配方</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="配方名称:" prop="ftname">
- <span>{{ table1.temp.ftname }}</span>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <h3 style="width: 160px;float: left;">体况评分标准</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="体况评分标准(分):" prop="bodystandard">
- <el-select v-model="table1.temp.bodystandard" filterable placeholder="评分标准" class="filter-item" style="width: 100%;">
- <el-option v-for="item in physicalList" :key="item.value" :label="item.label" :value="item.label" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="数据来源:" prop="bodysource">
- <el-input v-model="table1.temp.bodysource" type="textarea" placeholder="1-255字符":autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <h3 style="width: 160px;float: left;">粪便评分标准</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="粪便评分标准(分):" prop="dungstandard">
- <el-select v-model="table1.temp.dungstandard" filterable placeholder="粪便评分标准" class="filter-item" style="width: 100%;">
- <el-option v-for="item in faecesList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="数据来源:" prop="dungsource">
- <el-input v-model="table1.temp.dungsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="table1.dialogFormVisible = false;getList() ">关闭</el-button>
- <el-button class="success" :disabled="isokDisable" @click="updateData()">确认</el-button>
- </div>
- </div>
- </el-dialog>
- <!-- 宾州筛、粪便筛标准范围 -->
- <el-dialog :title="textMap[table2.dialogStatus]" :visible.sync="table2.dialogFormVisible" :close-on-click-modal="false" width="80%">
- <div class="app-add">
- <el-form ref="temp" :rules="table2.rules" :model="table2.temp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
- <el-row>
- <el-col :span="10">
- <h3 style="width: 160px;float: left;">牲畜类别</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="牲畜父类:" prop="parentname">
- <span>{{ table2.temp.parentname }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="牲畜子类:" prop="cowname">
- <span>{{ table2.temp.cowname }}</span>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <h3 style="width: 160px;float: left;">宾州筛</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="宾州筛一层(%):">
- <el-input-number v-model="table2.temp.bzonemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.bzonemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="宾州筛二层(%):">
- <el-input-number v-model="table2.temp.bztwomin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.bztwomax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="宾州筛三层(%):">
- <el-input-number v-model="table2.temp.bzthreemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.bzthreemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="宾州筛四层(%):">
- <el-input-number v-model="table2.temp.bzfourmin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.bzfourmax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="数据来源:" prop="bzsource">
- <el-input v-model="table2.temp.bzsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <h3 style="width: 160px;float: left;">粪便筛</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="粪便筛一层(%):">
- <el-input-number v-model="table2.temp.fbonemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.fbonemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="粪便筛二层(%):">
- <el-input-number v-model="table2.temp.fbtwomin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.fbtwomax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="粪便筛三层(%):">
- <el-input-number v-model="table2.temp.fbthreemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
- <span style="width: 1%;">-</span>
- <el-input-number v-model="table2.temp.fbthreemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="数据来源:" prop="fbsource">
- <el-input v-model="table2.temp.fbsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="table2.dialogFormVisible = false; getList2()">关闭</el-button>
- <el-button class="success" :disabled="isokDisable" @click="updateData()">确认</el-button>
- </div>
- </div>
- </el-dialog>
- </div>
- </el-tab-pane></el-tabs></div></template>
- <script>
- import { GetDataByName, PostDataByName, failproccess, GetDataByNames, checkButtons } from '@/api/common'
- import Cookies from 'js-cookie'
- import axios from 'axios'
- import { parseTime, json2excel } from '@/utils/index.js'
- import { getToken } from '@/utils/auth'
- export default {
- name: 'StandardParameters',
- data() {
- return {
- isRoleEdit: [],
- activeName: 'first',
- requestParams: [
- { name: 'getDictByName', offset: 0, pagecount: 0, params: ['评分标准'] },
- { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['粪便评分标准'] }
- ],
- physicalList: [], // 标准体况评分
- faecesList: [], // 标准粪便评分
- table1: {
- getdataListParm: {
- name: 'getOptscoreList',
- page: 1,
- offset: 1,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- enable: ''
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- // 编辑
- dialogFormVisible: false,
- dialogStatus: '',
- temp: {},
- rules: {
- bodystandard: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
- dungstandard: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- }
- },
- table2: {
- getdataListParm: {
- name: 'getOptrangeList',
- page: 1,
- offset: 1,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid')
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- // 编辑
- dialogFormVisible: false,
- dialogStatus: '',
- temp: {},
- rules: {}
- },
- download: {
- getdataListParm: {},
- list: []
- },
- textMap: {
- update: '编辑'
- },
- requestParam: {},
- isokDisable: false,
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' }
- }
- },
- computed: {
- // 设置请求头
- headers() {
- return {
- token: getToken()
- }
- },
- uploadData() {
- return {
- name: 'checkft,updateOptscoreUpload',
- importParams: '配方名称,体况评分标准(分),体况评分数据来源,粪便评分标准(分),粪便评分数据来源',
- sheetname: 'Sheet1',
- // 登录牧场
- pastureid: Cookies.get('pastureid'),
- // 日期参数
- dateParams: '',
- // 必填参数
- requiredParams: '配方名称,体况评分标准(分),粪便评分标准(分)',
- // 为数值的参数
- numParams: '体况评分标准(分),粪便评分标准(分)'
- }
- },
- // 设置上传地址
- uploadExcelUrl() {
- return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
- },
- headers2() {
- return {
- token: getToken()
- }
- },
- uploadData2() {
- return {
- name: 'checkbigcowclassW,checkclassnameW,insertOptrangeUpload',
- importParams: '牲畜父类,牲畜子类,宾州筛一层(%),宾州筛二层(%),宾州筛三层(%),宾州筛四层(%),宾州筛数据来源,粪便筛一层(%),粪便筛二层(%),粪便筛三层(%),粪便筛数据来源',
- sheetname: 'Sheet1',
- // 登录牧场
- pastureid: Cookies.get('pastureid'),
- // 日期参数
- dateParams: '',
- // 必填参数
- requiredParams: '牲畜父类,牲畜子类',
- // 为数值的参数
- numParams: ''
- }
- },
- // 设置上传地址
- uploadExcelUrl2() {
- return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
- }
- },
- created() {
- this.getList()
- this.getDownList()
- this.getButtons()
- },
- methods: {
- getButtons() {
- const Edit = 'StandardParameters'
- const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
- this.isRoleEdit = isRoleEdit
- },
- getDownList() {
- GetDataByNames(this.requestParams).then(response => {
- this.physicalList = response.data.getDictByName.list
- this.faecesList = response.data.getDictByName2.list
- })
- },
- handleTabClick(tab, event) {
- console.log(tab, event)
- if (tab.name === 'first') {
- this.getList()
- } else if (tab.name === 'second') {
- this.getList2()
- }
- },
- getList() {
- this.table1.listLoading = true
- GetDataByName(this.table1.getdataListParm).then(response => {
- console.log('table1数据', response.data.list)
- if (response.data.list !== null) {
- this.table1.list = response.data.list
- this.table1.total = response.data.total
- } else {
- this.table1.list = []
- }
- setTimeout(() => {
- this.table1.listLoading = false
- }, 100)
- })
- },
- getList2() {
- this.table2.listLoading = true
- GetDataByName(this.table2.getdataListParm).then(response => {
- console.log('table1数据', response.data.list)
- if (response.data.list !== null) {
- this.table2.list = response.data.list
- if (response.data.total) {
- this.table2.total = response.data.total
- }
- } else {
- this.table2.list = []
- }
- setTimeout(() => {
- this.table2.listLoading = false
- }, 100)
- })
- },
- // 编辑
- handleUpdate(row) {
- if (this.activeName === 'first') {
- console.log('点击了体况、粪便评分标准编辑')
- this.table1.dialogStatus = 'update'
- this.table1.dialogFormVisible = true
- this.table1.temp = Object.assign({}, row)
- } else if (this.activeName === 'second') {
- console.log('点击了宾州筛、粪便筛标准范围编辑')
- this.table2.dialogStatus = 'update'
- this.table2.dialogFormVisible = true
- this.table2.temp = Object.assign({}, row)
- }
- },
- updateData() {
- if (this.activeName === 'first') {
- console.log('点击了体况、粪便评分标准编辑保存')
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.$refs['temp'].validate(valid => {
- if (valid) {
- this.requestParam.name = 'updateOptscore'
- this.requestParam.parammaps = this.table1.temp
- PostDataByName(this.requestParam).then(response => {
- console.log('新增保存发送参数', this.requestParam)
- if (response.msg !== 'fail') {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- this.table1.dialogFormVisible = false
- this.getList()
- } else {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- }
- })
- }
- })
- } else if (this.activeName === 'second') {
- console.log('点击了宾州筛、粪便筛标准范围编辑保存')
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- // 若最小值大于最大值
- if (parseFloat(this.table2.temp.bzonemin) > parseFloat(this.table2.temp.bzonemax)) {
- this.$message({ type: 'error', message: '宾州筛一层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- if (parseFloat(this.table2.temp.bztwomin) > parseFloat(this.table2.temp.bztwomax)) {
- this.$message({ type: 'error', message: '宾州筛二层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- if (parseFloat(this.table2.temp.bzthreemin) > parseFloat(this.table2.temp.bzthreemax)) {
- this.$message({ type: 'error', message: '宾州筛三层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- if (parseFloat(this.table2.temp.bzfourmin) > parseFloat(this.table2.temp.bzfourmax)) {
- this.$message({ type: 'error', message: '宾州筛四层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- if (parseFloat(this.table2.temp.fbonemin) > parseFloat(this.table2.temp.fbonemax)) {
- this.$message({ type: 'error', message: '粪便筛一层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- if (parseFloat(this.table2.temp.fbtwomin) > parseFloat(this.table2.temp.fbtwomax)) {
- this.$message({ type: 'error', message: '粪便筛二层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- if (parseFloat(this.table2.temp.fbthreemin) > parseFloat(this.table2.temp.fbthreemax)) {
- this.$message({ type: 'error', message: '粪便筛三层最大值不可小于等于最小值', duration: 2000 })
- return false
- }
- // 若最大值最小值为空
- if (this.table2.temp.bzonemin == '' || this.table2.temp.bzonemin == undefined) { this.table2.temp.bzonemin = '0' }
- if (this.table2.temp.bzonemax == '' || this.table2.temp.bzonemax == undefined) { this.table2.temp.bzonemax = '0' }
- if (this.table2.temp.bztwomin == '' || this.table2.temp.bztwomin == undefined) { this.table2.temp.bztwomin = '0' }
- if (this.table2.temp.bztwomax == '' || this.table2.temp.bztwomax == undefined) { this.table2.temp.bztwomax = '0' }
- if (this.table2.temp.bzthreemin == '' || this.table2.temp.bzthreemin == undefined) { this.table2.temp.bzthreemin = '0' }
- if (this.table2.temp.bzthreemax == '' || this.table2.temp.bzthreemax == undefined) { this.table2.temp.bzthreemax = '0' }
- if (this.table2.temp.bzfourmin == '' || this.table2.temp.bzfourmin == undefined) { this.table2.temp.bzfourmin = '0' }
- if (this.table2.temp.bzfourmax == '' || this.table2.temp.bzfourmax == undefined) { this.table2.temp.bzfourmax = '0' }
- if (this.table2.temp.fbonemin == '' || this.table2.temp.fbonemin == undefined) { this.table2.temp.fbonemin = '0' }
- if (this.table2.temp.fbonemax == '' || this.table2.temp.fbonemax == undefined) { this.table2.temp.fbonemax = '0' }
- if (this.table2.temp.fbtwomin == '' || this.table2.temp.fbtwomin == undefined) { this.table2.temp.fbtwomin = '0' }
- if (this.table2.temp.fbtwomax == '' || this.table2.temp.fbtwomax == undefined) { this.table2.temp.fbtwomax = '0' }
- if (this.table2.temp.fbthreemin == '' || this.table2.temp.fbthreemin == undefined) { this.table2.temp.fbthreemin = '0' }
- if (this.table2.temp.fbthreemax == '' || this.table2.temp.fbthreemax == undefined) { this.table2.temp.fbthreemax = '0' }
- var positiveInteger = /^([0-9]{1,2}|100)$/
- if (!positiveInteger.test(parseFloat(this.table2.temp.bzonemin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bzonemax))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bztwomin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bztwomax))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bzthreemin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bzthreemax))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bzfourmin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.bzfourmax))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.fbonemin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.fbonemax))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.fbtwomin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.fbtwomax))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.fbthreemin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- if (!positiveInteger.test(parseFloat(this.table2.temp.fbthreemin))) {
- this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
- return false
- }
- this.requestParam.name = 'insertOptrange'
- this.requestParam.parammaps = this.table2.temp
- this.$refs['temp'].validate(valid => {
- if (valid) {
- PostDataByName(this.requestParam).then(response => {
- console.log('新增保存发送参数', this.requestParam)
- if (response.msg !== 'fail') {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- this.table2.dialogFormVisible = false
- this.getList2()
- this.activeName = 'second'
- } else {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- if (this.table2.temp.bzonemin == '0') { this.table2.temp.bzonemin = '' }
- if (this.table2.temp.bzonemax == '0') { this.table2.temp.bzonemax = '' }
- if (this.table2.temp.bztwomin == '0') { this.table2.temp.bztwomin = '' }
- if (this.table2.temp.bztwomax == '0') { this.table2.temp.bztwomax = '' }
- if (this.table2.temp.bzthreemin == '0') { this.table2.temp.bzthreemin = '' }
- if (this.table2.temp.bzthreemax == '0') { this.table2.temp.bzthreemax = '' }
- if (this.table2.temp.bzfourmin == '0') { this.table2.temp.bzfourmin = '' }
- if (this.table2.temp.bzfourmax == '0') { this.table2.temp.bzfourmax = '' }
- if (this.table2.temp.fbonemin == '0') { this.table2.temp.fbonemin = '' }
- if (this.table2.temp.fbonemax == '0') { this.table2.temp.fbonemax = '' }
- if (this.table2.temp.fbtwomin == '0') { this.table2.temp.fbtwomin = '' }
- if (this.table2.temp.fbtwomax == '0') { this.table2.temp.fbtwomax = '' }
- if (this.table2.temp.fbthreemin == '0') { this.table2.temp.fbthreemin = '' }
- if (this.table2.temp.fbthreemax == '0') { this.table2.temp.fbthreemax = '' }
- }
- })
- }
- })
- }
- },
- // 导出
- handleExport(item) {
- if (item == 1) {
- console.log('体况、粪便评分标准/导出')
- var downloadList = [
- { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
- { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
- { 'obj1': '3、配方名称,体况评分标准(分),粪便评分标准为必填;' },
- { 'obj1': '4、配方名称必须与系统中配方模板的配方名称匹配;' },
- { 'obj1': '5、标准分数为固定几个分值,分别为:2.75-,2.75,3,3.25,3.75,4+;粪便评分标准为1,2,3,4,5' },
- { 'obj1': '6、数据最多可导入200条,超过200条请分多个文件导入。' }
- ]
- var excelDatas = [
- {
- tHeader: ['配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源'],
- filterVal: ['ftname', '', '', '', ''],
- tableDatas: this.table1.list,
- sheetName: 'Sheet1'
- }, {
- tHeader: ['填写规范:'],
- filterVal: ['obj1'],
- tableDatas: downloadList,
- sheetName: 'Sheet2'
- }
- ]
- json2excel(excelDatas, '基础数据_体况、粪便评分标准导入模板', true, 'xlsx')
- } else if (item == 3) {
- console.log('宾州筛、粪便筛标准范围/导出')
- this.download.getdataListParm.name = 'getOptrangeList'
- this.download.getdataListParm.parammaps = {}
- this.download.getdataListParm.parammaps.pastureid = Cookies.get('pastureid')
- GetDataByName(this.download.getdataListParm).then(response => {
- if (response.data.list !== null) {
- this.download.list = response.data.list
- } else {
- this.download.list = []
- }
- var downloadList = [
- { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
- { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
- { 'obj1': '3、牲畜父类,牲畜子类为必填;' },
- { 'obj1': '4、牲畜类别必须与系统基础数据中牲畜类别匹配;' },
- { 'obj1': '5、数据最多可导入200条,超过200条请分多个文件导入。' }
- ]
- var excelDatas = [
- {
- tHeader: ['牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛一层(%)', '粪便筛二层(%)', '粪便筛三层(%)', '粪便筛数据来源'],
- filterVal: ['parentname', 'cowname', '', '', '', '', '', '', '', '', ''],
- tableDatas: this.download.list,
- sheetName: 'Sheet1'
- }, {
- tHeader: ['填写规范:'],
- filterVal: ['obj1'],
- tableDatas: downloadList,
- sheetName: 'Sheet2'
- }
- ]
- json2excel(excelDatas, '基础数据_宾州筛、粪便筛标准范围导入模板', true, 'xlsx')
- })
- } else if (item == 2) {
- console.log('体况评分导出数据', this.table1.list)
- import('@/vendor/Export5Excel').then(excel => {
- const multiHeader = [
- ['配方名称', '体况评分标准', '', '粪便评分标准', '']
- ]
- const multiHeader2 = [
- ['', '体况评分标准(分)', '数据来源', '粪便评分标准(分)', '数据来源']
- ]
- const filterVal = ['ftname', 'bodystandard', 'bodysource', 'dungstandard', 'dungsource']
- const data = this.table1.list.map((v) => filterVal.map((j) => v[j]))
- const merges = ['A1:A2', 'B1:C1', 'D1:E1']
- excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: '体况、粪便评分标准导出数据', merges })
- })
- } else if (item == 4) {
- var downList = []
- for (let i = 0; i < this.table2.list.length; i++) {
- var obj = {}
- obj.parentname = this.table2.list[i].parentname
- obj.cowname = this.table2.list[i].cowname
- obj.bzsource = this.table2.list[i].bzsource
- if (this.table2.list[i].bzonemin == undefined) { this.table2.list[i].bzonemin = '' }
- if (this.table2.list[i].bzonemax == undefined) { this.table2.list[i].bzonemax = '' }
- if (this.table2.list[i].bztwomin == undefined) { this.table2.list[i].bztwomin = '' }
- if (this.table2.list[i].bztwomax == undefined) { this.table2.list[i].bztwomax = '' }
- if (this.table2.list[i].bzthreemin == undefined) { this.table2.list[i].bzthreemin = '' }
- if (this.table2.list[i].bzthreemax == undefined) { this.table2.list[i].bzthreemax = '' }
- if (this.table2.list[i].bzfourmin == undefined) { this.table2.list[i].bzfourmin = '' }
- if (this.table2.list[i].bzfourmax == undefined) { this.table2.list[i].bzfourmax = '' }
- if (this.table2.list[i].fbonemin == undefined) { this.table2.list[i].fbonemin = '' }
- if (this.table2.list[i].fbonemax == undefined) { this.table2.list[i].fbonemax = '' }
- if (this.table2.list[i].fbtwomin == undefined) { this.table2.list[i].fbtwomin = '' }
- if (this.table2.list[i].fbtwomax == undefined) { this.table2.list[i].fbtwomax = '' }
- if (this.table2.list[i].fbthreemin == undefined) { this.table2.list[i].fbthreemin = '' }
- if (this.table2.list[i].fbthreemax == undefined) { this.table2.list[i].fbthreemax = '' }
- obj.one1 = this.table2.list[i].bzonemin + '-' + this.table2.list[i].bzonemax
- obj.two1 = this.table2.list[i].bztwomin + '-' + this.table2.list[i].bztwomax
- obj.three1 = this.table2.list[i].bzthreemin + '-' + this.table2.list[i].bzthreemax
- obj.four1 = this.table2.list[i].bzfourmin + '-' + this.table2.list[i].bzfourmax
- obj.one2 = this.table2.list[i].fbonemin + '-' + this.table2.list[i].fbonemax
- obj.two2 = this.table2.list[i].fbtwomin + '-' + this.table2.list[i].fbtwomax
- obj.three2 = this.table2.list[i].fbthreemin + '-' + this.table2.list[i].fbthreemax
- obj.fbsource = this.table2.list[i].fbsource
- downList.push(obj)
- }
- import('@/vendor/Export5Excel').then(excel => {
- const multiHeader = [
- ['牲畜类别', '', '宾州筛', '', '', '', '', '粪便筛', '', '', '']
- ]
- const multiHeader2 = [
- ['牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '数据来源', '粪便筛一层(%)', '粪便筛二层(%)', '粪便筛三层(%)', '数据来源']
- ]
- const filterVal = ['parentname', 'cowname', 'one1', 'two1', 'three1', 'four1', 'bzsource', 'one2', 'two2', 'three2', 'fbsource']
- const data = downList.map((v) => filterVal.map((j) => v[j]))
- const merges = ['A1:B1', 'C1:G1', 'H1:K1']
- excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: '宾州筛、粪便筛标准范围导出数据', merges })
- })
- }
- },
- beforeImport(file) {
- const isLt2M = file.size / 1024 / 1024 < 2
- if (!isLt2M) {
- this.$message.error('上传文件大小不能超过 2MB!')
- }
- return isLt2M
- },
- handleImportSuccess(res, file) {
- this.getList()
- if (res.msg === 'ok') {
- this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
- if (res.data.err_count > 0) {
- this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
- import('@/vendor/Export2Excel').then(excel => {
- const list1 = res.data.result
- const tHeader = [
- '配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源', '错误信息'
- ]
- const filterVal = [
- '配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源', 'error_msg'
- ]
- const data1 = this.formatJson(filterVal, list1)
- excel.export_json_to_excel({ header: tHeader, data: data1, filename: '体况、粪便评分导入报错信息', autoWidth: true, bookType: 'xlsx' })
- })
- }
- } else {
- this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
- }
- },
- formatJson(filterVal, jsonData) {
- return jsonData.map(v =>
- filterVal.map(j => {
- if (j === 'timestamp') {
- return parseTime(v[j])
- } else {
- return v[j]
- }
- })
- )
- },
- beforeImport2(file) {
- const isLt2M = file.size / 1024 / 1024 < 2
- if (!isLt2M) {
- this.$message.error('上传文件大小不能超过 2MB!')
- }
- return isLt2M
- },
- handleImportSuccess2(res, file) {
- this.getList2()
- if (res.msg === 'ok') {
- this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
- if (res.data.err_count > 0) {
- this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
- import('@/vendor/Export2Excel').then(excel => {
- const list1 = res.data.result
- const tHeader = [
- '牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛二层(%)', '粪便筛三层(%)', '粪便筛数据来源', '错误信息'
- ]
- const filterVal = [
- '牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛二层(%)', '粪便筛三层(%)', '粪便筛数据来源', 'error_msg'
- ]
- const data1 = this.formatJson2(filterVal, list1)
- excel.export_json_to_excel({ header: tHeader, data: data1, filename: '宾州筛、粪便筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
- })
- }
- } else {
- this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
- }
- },
- formatJson2(filterVal, jsonData) {
- return jsonData.map(v =>
- filterVal.map(j => {
- if (j === 'timestamp') {
- return parseTime(v[j])
- } else {
- return v[j]
- }
- })
- )
- }
- // 导入
- // handleImport() {
- // if (this.activeName === 'first') {
- // console.log('体况、粪便评分标准/导入')
- // } else if (this.activeName === 'second') {
- // console.log('宾州筛、粪便筛标准范围/导入')
- // }
- // }
- }
- }
- </script>
- <style lang="scss" scoped>
- // .operation{
- // position: relative;
- // height: 50px;
- // .export{position: absolute;right: 110px;bottom: 10px;}
- // .import{position: absolute;right: 0;bottom: 10px;}
- // }
- </style>
|