| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 | <template>  <div class="app-container">    <el-tabs v-model="activeName" @tab-click="handleClick">      <el-tab-pane label="预混记录" name="first">        <div class="table">          <el-table            :key="tab1.tableKey"            v-loading="tab1.listLoading"            element-loading-text="给我一点时间"            :data="tab1.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" prop="pftname" />            <el-table-column label="当前剩余量" min-width="110px" align="center">              <template slot-scope="scope">                <span v-if="scope.row.NoEdit">{{ scope.row.stockweight }}</span>                <el-input v-if="scope.row.Edit" v-model="scope.row.stockweight" type="number" style="width:95%;padding:10px 0;" />              </template>            </el-table-column>            <el-table-column label="预计使用天数" min-width="130px" align="center" prop="days" />            <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">              <template slot-scope="{row}">                <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">校正</el-button>                <el-button v-if="row.isUpdateSave" :disabled="isokDisable" class="miniSuccess" @click="updateData(row)">保存</el-button>                <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>              </template>            </el-table-column>          </el-table>        </div>      </el-tab-pane>      <el-tab-pane label="库存预警" name="second">        <div class="operation">          <el-button class="import" style="float: right;margin-bottom: 10px;" @click="handleExport">导出</el-button>        </div>        <div class="table">          <el-table            :key="table.tableKey"            v-loading="table.listLoading"            element-loading-text="给我一点时间"            :data="table.list"            border            fit            highlight-current-row            style="width: 100%;"            :cell-style="cellStyle"            class="elTable table-fixed"            :row-style="rowStyle"          >            <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.feedname }}</span>              </template>            </el-table-column>            <el-table-column label="库存量(kg)" min-width="130px" align="center">              <template slot-scope="scope">                <span>{{ scope.row.stockweight }}</span>              </template>            </el-table-column>            <el-table-column label="近七天平均计划量(kg)" min-width="110px" align="center">              <template slot-scope="scope">                <span>{{ scope.row.avgweight }}</span>              </template>            </el-table-column>            <el-table-column label="剩余使用天数" min-width="110px" align="center">              <template slot-scope="scope">                <span>{{ scope.row.ldays }}</span>              </template>            </el-table-column>            <el-table-column label="最近预警日期" min-width="110px" align="center">              <template slot-scope="scope">                <span>{{ scope.row.lastdate }}</span>              </template>            </el-table-column>            <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">              <template slot-scope="{row}">                <el-button class="miniPrimary" :disabled="isokDisable" @click="handleSee(row)">查看</el-button>              </template>            </el-table-column>          </el-table>        </div>      </el-tab-pane>    </el-tabs>    <el-dialog :title="textMap[see.dialogStatus]" :visible.sync="see.dialogFormVisible" :close-on-click-modal="false" width="90%">      <div class="app-see">        <el-form ref="temp" :rules="see.rules" :model="see.temp" label-position="right" label-width="110px" style="width: 100%;margin:0 auto">          <el-row>            <el-col :span="8">              <el-form-item label="饲料名称:" prop="feedname">                <span> {{ see.temp.feedname }}</span>              </el-form-item>            </el-col>          </el-row>        </el-form>        <el-table          :key="see.tableKey"          v-loading="see.listLoading"          element-loading-text="给我一点时间"          :data="see.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">            <template slot-scope="scope">              <span>{{ scope.$index + (see.pageNum-1) * see.pageSize + 1 }}</span>            </template>          </el-table-column>          <el-table-column label="库存量" min-width="130px" align="center">            <template slot-scope="scope">              <span>{{ scope.row.stockweight }}</span>            </template>          </el-table-column>          <el-table-column label="近七天平均计划量(kg)" min-width="130px" align="center">            <template slot-scope="scope">              <span>{{ scope.row.avgweight }}</span>            </template>          </el-table-column>          <el-table-column label="剩余使用天数" min-width="110px" align="center">            <template slot-scope="scope">              <span> {{ scope.row.ldays }}</span>            </template>          </el-table-column>          <el-table-column label="预警日期" min-width="110px" align="center">            <template slot-scope="scope">              <span>{{ scope.row.date }}</span>            </template>          </el-table-column>        </el-table>        <pagination v-show="see.total>=0" style="margin-bottom: 50px;" :total="see.total" :page.sync="see.getdataListParm.offset" :limit.sync="see.getdataListParm.pagecount" @pagination="getSeeList" />        <div slot="footer" class="dialog-footer">          <el-button class="cancelClose" @click="see.dialogFormVisible = false; ">关闭</el-button>        </div>      </div>    </el-dialog>  </div></template><script>import { GetDataByName, PostDataByName, failproccess } from '@/api/common'import Pagination from '@/components/Pagination'import Cookies from 'js-cookie'import { json2excel } from '@/utils/index.js'export default {  name: 'Warning',  components: { Pagination },  data() {    return {      activeName: 'first',      tab1: {        getdataListParm: {          name: 'getPreMixStorageLsit',          page: 1,          offset: 1,          pagecount: '',          returntype: 'Map',          parammaps: {            pastureid: Cookies.get('pastureid')          }        },        tableKey: 0,        list: [],        total: 0,        listLoading: true      },      table: {        getdataListParm: {          name: 'getFsWarnList',          page: 1,          offset: 1,          pagecount: '',          returntype: 'Map',          parammaps: {            pastureid: Cookies.get('pastureid')          }        },        tableKey: 0,        list: [],        total: 0,        listLoading: true      },      textMap: {        see: '库存预警记录'      },      see: {        dialogFormVisible: false,        dialogStatus: '',        temp: {},        rules: {},        getdataListParm: {          name: 'getFsWarnListdate',          page: 1,          offset: 1,          pagecount: 10,          returntype: 'Map',          parammaps: {            pastureid: Cookies.get('pastureid'),            feedid: ''          }        },        tableKey: 0,        list: [],        total: 0,        listLoading: true      },      download: {        getdataListParm: {          name: 'getFsWarnList',          page: 1,          offset: 1,          pagecount: 0,          returntype: 'Map',          parammaps: {            pastureid: Cookies.get('pastureid')          }        },        list: []      },      requestParam: {},      isokDisable: false,      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },      cellStyle: { padding: 0 + 'px' }    }  },  created() {    this.getTab1List()    this.getList()  },  methods: {    handleClick(item) {      console.log(item)    },    getTab1List() {      this.tab1.listLoading = true      GetDataByName(this.tab1.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], 'isCreate', false) // 新增操作            this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作            this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存          }          this.tab1.list = response.data.list          this.tab1.pageNum = response.data.pageNum          this.tab1.pageSize = response.data.pageSize          this.tab1.total = response.data.total        } else {          this.tab1.list = []        }        setTimeout(() => {          this.tab1.listLoading = false        }, 100)      })    },    handleUpdate(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,编辑false,编辑保存true      row.isCreate = false      row.isUpdate = false      row.isUpdateSave = true    },    updateData(row) {      this.isokDisable = true      setTimeout(() => {        this.isokDisable = false      }, 1000)      if (row.stockweight == '') {        this.$message({ type: 'error', message: '当前配方剩余重量不能为空', duration: 2000 })        return false      }      const keepTwoNum = /^\d+(\.\d{1,2})?$/      // 当前配方剩余重量      if (!keepTwoNum.test(parseFloat(row.stockweight))) {        this.$message({ type: 'error', message: '当前配方剩余重量请输入自然数并保留两位小数', duration: 2000 })        return false      }      this.requestParam.name = 'updatePreMixStorage'      this.requestParam.parammaps = {}      this.requestParam.parammaps.pastureid = row.pastureid      this.requestParam.parammaps.id = row.id      this.requestParam.parammaps.stockweight = row.stockweight      PostDataByName(this.requestParam).then(response => {        console.log('编辑保存发送参数', this.requestParam)        if (response.msg !== 'fail') {          this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })          this.getTab1List()        } else {          this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })        }      })    },    updateCancel(row) {      console.log('点击了编辑取消')      // 编辑false,不可编辑true      row.Edit = false      row.NoEdit = true      // 新增false,编辑true,编辑保存false      row.isCreate = false      row.isUpdate = true      row.isUpdateSave = false      this.getTab1List()    },    getList() {      this.table.listLoading = true      GetDataByName(this.table.getdataListParm).then(response => {        console.log('table数据', response.data.list)        if (response.data.list !== null) {          this.table.list = response.data.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)      })    },    handleSee(row) {      this.see.dialogStatus = 'see'      this.see.dialogFormVisible = true      this.see.temp = Object.assign({}, row)      this.see.list = []      this.see.getdataListParm.offset = 1      this.see.getdataListParm.parammaps.feedid = row.feedid      this.getSeeList()    },    getSeeList() {      this.see.listLoading = true      GetDataByName(this.see.getdataListParm).then(response => {        console.log('table数据', response.data.list)        if (response.data.list !== null) {          this.see.list = response.data.list          this.see.pageNum = response.data.pageNum          this.see.pageSize = response.data.pageSize          this.see.total = response.data.total        } else {          this.see.list = []        }        setTimeout(() => {          this.see.listLoading = false        }, 100)      })    },    handleExport() {      console.log('导出')      GetDataByName(this.download.getdataListParm).then(response => {        if (response.data.list !== null) {          this.download.list = response.data.list        } else {          this.download.list = []        }        var excelDatas = [          {            tHeader: ['饲料名称', '库存量(kg)', '近七天平均计划量(kg)', '剩余使用天数', '最新预警日期'],            filterVal: ['feedname', 'stockweight', 'avgweight', 'ldays', 'lastdate'],            tableDatas: this.download.list,            sheetName: 'Sheet1'          }        ]        json2excel(excelDatas, '库存预警', true, 'xlsx')      })    }  }}</script>
 |