12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190 |
- <template>
- <div class="app-container">
- <div class="operation">
- <el-button class="success" @click="handleCreate">新增入库单</el-button>
- <el-button class="success" @click="handleInitial">初始化库存</el-button>
- <el-upload 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="search">
- <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
- <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
- <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
- <el-select v-model="table.getdataListParm.parammaps.feedid" placeholder="饲料名称" class="filter-item" style="width: 150px;" clearable>
- <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
- </el-select>
- <el-select v-model="table.getdataListParm.parammaps.providerid" placeholder="供应商" class="filter-item" style="width: 150px;" clearable>
- <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
- </el-select>
- <el-select v-model="table.getdataListParm.parammaps.islaid" placeholder="是否入库" class="filter-item" style="width: 150px;" clearable>
- <el-option v-for="item in islaidList" :key="item.id" :label="item.name" :value="item.name" />
- </el-select>
- <el-button class="successBorder" @click="handleSearch">查询</el-button>
- <el-button class="successBorder" @click="handleRefresh">重置</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%;"
- :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 + (table.pageNum-1) * table.pageSize + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="入库日期" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.laiddate }}</span>
- </template>
- </el-table-column>
- <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="供应商" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.providername }}</span>
- </template>
- </el-table-column>
- <el-table-column label="入库重量(kg)" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.operateweight }}</span>
- </template>
- </el-table-column>
- <el-table-column label="总价(元)" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sumprice }}</span>
- </template>
- </el-table-column>
- <el-table-column label="批号" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.pcpde }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.remark }}</span>
- </template>
- </el-table-column>
- <el-table-column label="是否入库" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.islaid }}</span>
- </template>
- </el-table-column>
- <el-table-column label="创建人" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.createemp }}</span>
- </template>
- </el-table-column>
- <el-table-column label="创建日期" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.createdate }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <el-button class="miniPrimary" @click="handleSee(row)">查看</el-button>
- <el-button v-if="row.islaid == '否'" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
- </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 :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
- <div class="app-add">
- <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
- <el-row>
- <el-col :span="24">
- <h3 style="width: 160px;text-align: right;">基础信息</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="入库日期:" prop="laiddate">
- <el-date-picker v-model="create.createTemp.laiddate" :disabled="create.dialogStatus=='see'" class="filter-item" type="date" placeholder="入库日期" :clearable="false" :picker-options="create.pickerOptions1" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="送货单编号:" prop="wagonnumber">
- <el-input ref="wagonnumber" v-model="create.createTemp.wagonnumber" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="送货单编号" type="text" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="饲料名称:" prop="feedname">
- <el-autocomplete
- v-model="create.createTemp.feedname"
- value-key="fname"
- class="inline-input"
- :fetch-suggestions="feedNameSearch"
- placeholder="请选择饲料名称"
- style="width:98%"
- :disabled="create.dialogStatus=='see' || create.dialogStatus=='update'"
- @select="handleSelectFeedName"
- @blur="blurFeedName"
- >
- <template slot-scope="{ item }">
- <span>{{ item.fname }}</span>
- </template>
- </el-autocomplete>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="入库重量(kg):" prop="operateweight">
- <el-input ref="operateweight" v-model.trim="create.createTemp.operateweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurOperateweight" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="供应商:" prop="providerid">
- <el-select v-model="create.createTemp.providerid" clearable placeholder="请选择供应商" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeSupplier">
- <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="合同编号:" prop="contractcode">
- <el-select v-model="create.createTemp.contractcode" clearable placeholder="请选择合同编号" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeContractNo">
- <el-option v-for="item in contractNoList" :key="item.id" :label="item.contractcodeCat" :value="item.contractcode" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <h3 style="width: 160px;text-align: right;">价格信息</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="单价(元):" prop="pricenew">
- <el-input ref="pricenew" v-model="create.createTemp.pricenew" :disabled="create.createTemp.contractcode !=='' || create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurPricenew" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="总价(元):" prop="sumprice">
- <el-input ref="sumprice" v-model="create.createTemp.sumprice" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurSumprice" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <h3 style="width: 160px;text-align: right;">饲料信息</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="毛重:" prop="grossweight">
- <el-input ref="grossweight" v-model.trim="create.createTemp.grossweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurGrossweight" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="皮重:" prop="tareweight">
- <el-input ref="tareweight" v-model.trim="create.createTemp.tareweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurTareweight" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="许可证号:" prop="licence">
- <el-input ref="licence" v-model="create.createTemp.licence" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="许可证号" type="text" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="批号:" prop="pcpde">
- <el-input ref="pcpde" v-model="create.createTemp.pcpde" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="批号" type="text" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <h3 style="width: 160px;text-align: right;">操作信息</h3>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="创建人:" prop="createemp">
- <el-input ref="createemp" v-model="create.createTemp.createemp" class="filter-item" placeholder="创建人" type="text" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="创建日期:" prop="createdate">
- <el-date-picker v-model="create.createTemp.createdate" class="filter-item" type="date" placeholder="创建日期" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="备注:" prop="remark">
- <el-input ref="remark" v-model="create.createTemp.remark" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="1-255字符" type="text" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList(); ">关闭</el-button>
- <el-button v-if="create.dialogStatus !== 'see' " class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
- </div>
- </div>
- </el-dialog>
- <!-- 初始化库存 -->
- <el-dialog :title="textMap[initial.dialogStatus]" :visible.sync="initial.dialogFormVisible" :close-on-click-modal="false" width="80%" height="55%">
- <div class="app-add" style="height: 100%;margin: 0 auto 60px;">
- <div class="operation">
- <el-button style="float: left;margin-bottom:10px;" class="success" @click="handleInitialExport">模板下载</el-button>
- <el-upload style="float: left;margin-left: 10px;margin-bottom:10px;" action="" :auto-upload="false" accept=".xlsx, .xls" :show-file-list="false" :on-change="handleInitialImport">
- <el-button class="success">导入</el-button>
- </el-upload>
- </div>
- <div class="table">
- <el-table
- :key="initial.tableKey"
- v-loading="initial.listLoading"
- element-loading-text="给我一点时间"
- :data="initial.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.fname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="库存重量" min-width="130px" align="center">
- <template slot-scope="scope">
- <el-input v-model="scope.row.stockweight" placeholder="最多两位小数" type="number" :step="0.01" style="width:95%;padding:10px 0;" />
- </template>
- </el-table-column>
- </el-table>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="initial.dialogFormVisible = false; ">关闭</el-button>
- <el-button class="success" :disabled="isokDisable" @click="initialData()">确认</el-button>
- </div>
- </div>
- </div></el-dialog>
- </div>
- </template>
- <script>
- import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess } from '@/api/common'
- import Pagination from '@/components/Pagination'
- import { MessageBox } from 'element-ui'
- import Cookies from 'js-cookie'
- import { json2excel, parseTime } from '@/utils/index.js'
- import { getToken } from '@/utils/auth'
- import xlsx from 'xlsx'
- import { upload } from '@/utils/index.js'
- export default {
- name: 'Warehousing',
- components: { Pagination },
- data() {
- return {
- feedNameList: [], // 饲料名称
- feedNameAddList: [], // 饲料名称新增
- supplierList: [], // 供应商
- contractNoList: [], // 合同编号
- islaidList: [{ id: 0, name: '是' }, { id: 1, name: '否' }], // 是否入库
- requestParams: [
- { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
- { name: 'getProviderListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
- ],
- table: {
- getdataListParm: {
- name: 'getFeedlaidList',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- inputDatetime: '',
- startTime: '',
- stopTime: '',
- feedid: '',
- islaid: '',
- providerid: ''
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true
- },
- create: {
- dialogFormVisible: false,
- dialogStatus: '',
- pickerOptions1: {
- disabledDate(time) {
- return time.getTime() > Date.now()// 当天之前的时间可选
- }
- },
- createTemp: {
- laiddate: '', feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: '', createdate: '', remark: '', 'wagonnumber': ''
- },
- rules: {
- laiddate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
- feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
- pricenew: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
- },
- getdataListParm: {
- name: 'getBigContractListEnable',
- offset: 0,
- pagecount: '',
- parammaps: { pastureid: Cookies.get('pastureid') }
- },
- getfeedNameParm: {
- name: 'getFeedListEnableV2',
- offset: 0,
- pagecount: '',
- parammaps: { pastureid: Cookies.get('pastureid') }
- }
- },
- initial: {
- dialogFormVisible: false,
- dialogStatus: '',
- rules: {},
- getdataListParm: {
- name: 'getinitFeed',
- page: 1,
- offset: 1,
- pagecount: 6,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid')
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- character: {
- fname: {
- text: '饲料名称',
- type: String
- },
- stockweight: {
- text: '库存重量',
- type: String
- }
- }
- },
- textMap: {
- create: '新增入库单',
- update: '编辑入库单',
- see: '查看入库单',
- initial: '初始化库存'
- },
- requestParam: {},
- download: {
- getdataListParm: {
- name: 'getFeedlaidList',
- page: 1,
- offset: 1,
- pagecount: 0,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- inputDatetime: '',
- startTime: '',
- stopTime: '',
- feedid: '',
- islaid: '',
- providerid: ''
- }
- },
- list: []
- },
- isokDisable: false,
- isRoleEdit: [],
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' }
- }
- },
- computed: {
- // 设置请求头
- headers() {
- return {
- token: getToken()
- }
- },
- uploadData() {
- return {
- name: '颛孙洋洋-入库',
- importParams: '入库日期,送货单编号,饲料名称,供应商,合同编号,入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg),许可证号,批号,创建人,创建日期,备注',
- sheetname: 'SheetJS'
- }
- },
- // 设置上传地址
- uploadExcelUrl() {
- return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
- }
- },
- created() {
- this.getButtons()
- this.getDownList()
- this.getList()
- },
- methods: {
- getButtons() {
- const Edit = 'Warehousing'
- const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
- this.isRoleEdit = isRoleEdit
- },
- getDownList() {
- GetDataByNames(this.requestParams).then(response => {
- this.feedNameList = response.data.getFeedListEnable.list
- this.supplierList = response.data.getProviderListEnable.list
- })
- },
- handleBefore() {
- if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
- var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
- var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
- this.table.getdataListParm.parammaps.inputDatetime.length = 0
- this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
- this.$forceUpdate()
- }
- },
- handleNext() {
- if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
- var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
- var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
- this.table.getdataListParm.parammaps.inputDatetime.length = 0
- this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
- this.$forceUpdate()
- }
- },
- 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)
- })
- },
- handleSearch() {
- // console.log('点击了查询')
- if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
- this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
- this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
- } else {
- this.table.getdataListParm.parammaps.inputDatetime = ''
- this.table.getdataListParm.parammaps.startTime = ''
- this.table.getdataListParm.parammaps.stopTime = ''
- }
- this.table.getdataListParm.offset = 1
- this.getList()
- },
- handleRefresh() {
- console.log('点击了重置')
- this.table.getdataListParm.parammaps.inputDatetime = ''
- this.table.getdataListParm.parammaps.startTime = ''
- this.table.getdataListParm.parammaps.stopTime = ''
- this.table.getdataListParm.parammaps.feedid = ''
- this.table.getdataListParm.parammaps.islaid = ''
- this.table.getdataListParm.parammaps.providerid = ''
- this.table.getdataListParm.offset = 1
- },
- resetCreateTemp() {
- this.create.createTemp = {
- pastureid: Cookies.get('pastureid'), laiddate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: Cookies.get('employename'), createdate: parseTime(new Date(), '{y}-{m}-{d}'), remark: '', 'wagonnumber': ''
- }
- this.contractNoList = []
- },
- // 供应商
- changeSupplier(item) {
- console.log(item)
- if (item !== '') {
- this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
- } else {
- this.create.createTemp.providername = ''
- this.create.createTemp.contractcode = ''
- this.create.createTemp.pricenew = ''
- this.create.createTemp.sumprice = ''
- this.contractNoList = []
- }
- if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
- this.getContractNoList()
- }
- },
- // 合同编号
- changeContractNo(item) {
- if (item !== '') {
- this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
- } else {
- this.create.createTemp.pricenew = ''
- }
- if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
- this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
- this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
- }
- },
- getContractNoList() {
- this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
- this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
- GetDataByName(this.create.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- this.contractNoList = response.data.list
- this.create.createTemp.contractcode = ''
- this.create.createTemp.pricenew = ''
- this.create.createTemp.sumprice = ''
- } else {
- this.contractNoList = []
- this.create.createTemp.contractcode = ''
- this.create.createTemp.pricenew = ''
- this.create.createTemp.sumprice = ''
- }
- })
- },
- feedNameSearch(queryString, cb) {
- this.create.getfeedNameParm.parammaps['fname'] = queryString
- GetDataByName(this.create.getfeedNameParm).then(response => {
- console.log('模糊查询搜索data', response.data.list)
- if (response.data.list == null) {
- cb([])
- } else {
- cb(response.data.list)
- }
- })
- },
- handleSelectFeedName(item) {
- console.log('模糊查询选中值', item)
- this.create.createTemp.feedname = item.fname
- this.create.createTemp.feedid = item.id
- this.create.createTemp.startweight = item.stockweight
- this.create.createTemp.priceold = item.price
- this.create.createTemp.providerid = ''
- this.create.createTemp.providername = ''
- this.create.createTemp.contractcode = ''
- this.create.createTemp.pricenew = ''
- this.create.createTemp.sumprice = ''
- if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
- this.getContractNoList()
- }
- },
- blurFeedName() {
- this.create.createTemp.feedname = ''
- this.create.createTemp.feedid = ''
- this.create.createTemp.startweight = ''
- this.create.createTemp.priceold = ''
- this.create.createTemp.providerid = ''
- this.create.createTemp.providername = ''
- this.create.createTemp.contractcode = ''
- this.create.createTemp.pricenew = ''
- this.create.createTemp.sumprice = ''
- },
- // 入库重量
- blurOperateweight() {
- // 毛重grossweight皮重tareweight入库重量operateweight
- if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
- this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
- }
- if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
- if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
- this.create.createTemp.grossweight = this.create.createTemp.operateweight
- this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
- }
- }
- if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
- if (this.create.createTemp.operateweight == '') {
- this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
- }
- if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
- this.create.createTemp.tareweight = this.create.createTemp.grossweight
- this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
- }
- }
- if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
- this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
- this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
- } else {
- this.create.createTemp.sumprice = ''
- }
- },
- // 毛重
- blurGrossweight() {
- // 毛重grossweight皮重tareweight入库重量operateweight
- if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
- this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
- }
- if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
- if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
- this.create.createTemp.grossweight = this.create.createTemp.operateweight
- this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
- }
- }
- },
- // 皮重
- blurTareweight() {
- // 毛重grossweight皮重tareweight入库重量operateweight
- if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
- this.create.createTemp.grossweight = parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight)
- }
- if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
- if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
- this.create.createTemp.grossweight = this.create.createTemp.operateweight
- this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
- }
- }
- if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
- if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
- this.create.createTemp.tareweight = this.create.createTemp.grossweight
- this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
- }
- }
- },
- // 单价
- blurPricenew() {
- if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
- this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
- this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
- } else {
- this.create.createTemp.sumprice = ''
- }
- },
- // 总价
- blurSumprice() {
- if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
- this.create.createTemp.operateweight = parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew)
- this.create.createTemp.operateweight = this.create.createTemp.operateweight.toFixed(2)
- } else {
- this.create.createTemp.operateweight = ''
- }
- },
- handleCreate() {
- console.log('点击了新增入库单')
- this.resetCreateTemp()
- this.create.dialogStatus = 'create'
- this.create.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs.createTemp.resetFields()
- })
- },
- createData() {
- this.$refs['createTemp'].validate(valid => {
- if (valid) {
- if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
- this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
- return false
- }
- if (this.create.createTemp.sumprice.length > 15) {
- this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
- }
- const keepTwoNum = /^\d+(\.\d{1,2})?$/
- // 入库重量
- if (this.create.createTemp.operateweight !== '') {
- if (this.create.createTemp.operateweight == 0) {
- this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
- this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- // 单价
- if (this.create.createTemp.pricenew == 0) {
- this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
- this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- // 总价
- if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
- if (this.create.createTemp.sumprice == 0) {
- this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
- this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- // 毛重
- if (this.create.createTemp.grossweight !== '') {
- if (this.create.createTemp.grossweight == 0) {
- this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
- this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- // 皮重
- if (this.create.createTemp.tareweight !== '') {
- if (this.create.createTemp.tareweight == 0) {
- this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
- this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.requestParam.common = { 'returnmap': '0' }
- this.requestParam.data = []
- this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
- 'pastureid': this.create.createTemp.pastureid,
- 'laiddate': this.create.createTemp.laiddate,
- 'feedid': this.create.createTemp.feedid,
- 'feedname': this.create.createTemp.feedname,
- 'providerid': this.create.createTemp.providerid,
- 'providername': this.create.createTemp.providername,
- 'contractcode': this.create.createTemp.contractcode,
- 'operateweight': this.create.createTemp.operateweight,
- 'grossweight': this.create.createTemp.grossweight,
- 'tareweight': this.create.createTemp.tareweight,
- 'sumprice': this.create.createTemp.sumprice,
- 'licence': this.create.createTemp.licence,
- 'pcpde': this.create.createTemp.pcpde,
- 'remark': this.create.createTemp.remark,
- 'createdate': this.create.createTemp.createdate,
- 'createemp': this.create.createTemp.createemp,
- 'startweight': this.create.createTemp.startweight,
- 'priceold': this.create.createTemp.priceold,
- 'pricenew': this.create.createTemp.pricenew,
- 'wagonnumber': this.create.createTemp.wagonnumber
- }}
- if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
- this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
- 'operateweight': this.create.createTemp.operateweight,
- 'pastureid': this.create.createTemp.pastureid,
- 'feedid': this.create.createTemp.feedid,
- 'fname': this.create.createTemp.fname,
- 'pcpde': this.create.createTemp.pcpde,
- 'stockweight': this.create.createTemp.startweight,
- 'price': this.create.createTemp.pricenew
- }}
- }
- console.log('点击了新增入库单保存', this.requestParam)
- ExecDataByConfig(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- failproccess(response, this.$notify)
- } else {
- this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
- this.create.dialogFormVisible = false
- this.getList()
- }
- })
- })
- }
- })
- },
- handleUpdate(row) {
- console.log('点击了编辑')
- this.$nextTick(() => {
- this.$refs.createTemp.resetFields()
- })
- this.create.dialogStatus = 'update'
- this.create.dialogFormVisible = true
- row.feedid = String(row.feedid)
- this.create.createTemp = Object.assign({}, row)
- },
- updateData() {
- this.$refs['createTemp'].validate(valid => {
- if (valid) {
- if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
- this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
- return false
- }
- if (this.create.createTemp.sumprice.length > 15) {
- this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
- }
- const keepTwoNum = /^\d+(\.\d{1,2})?$/
- // 入库重量
- if (this.create.createTemp.operateweight !== '') {
- if (this.create.createTemp.operateweight == 0) {
- this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
- this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- // 单价
- if (this.create.createTemp.pricenew == 0) {
- this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
- this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- // 总价
- if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
- if (this.create.createTemp.sumprice == 0) {
- this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
- this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- // 毛重
- if (this.create.createTemp.grossweight !== '') {
- if (this.create.createTemp.grossweight == 0) {
- this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
- this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- // 皮重
- if (this.create.createTemp.tareweight !== '') {
- if (this.create.createTemp.tareweight == 0) {
- this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
- return false
- } else {
- if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
- this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
- return false
- }
- }
- }
- MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.requestParam.common = { 'returnmap': '0' }
- this.requestParam.data = []
- this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
- 'pastureid': this.create.createTemp.pastureid,
- 'id': this.create.createTemp.id,
- 'laiddate': this.create.createTemp.laiddate,
- 'feedid': this.create.createTemp.feedid,
- 'feedname': this.create.createTemp.feedname,
- 'providerid': this.create.createTemp.providerid,
- 'providername': this.create.createTemp.providername,
- 'contractcode': this.create.createTemp.contractcode,
- 'operateweight': this.create.createTemp.operateweight,
- 'grossweight': this.create.createTemp.grossweight,
- 'tareweight': this.create.createTemp.tareweight,
- 'sumprice': this.create.createTemp.sumprice,
- 'licence': this.create.createTemp.licence,
- 'pcpde': this.create.createTemp.pcpde,
- 'remark': this.create.createTemp.remark,
- 'createdate': this.create.createTemp.createdate,
- 'createemp': this.create.createTemp.createemp,
- 'startweight': this.create.createTemp.startweight,
- 'priceold': this.create.createTemp.priceold,
- 'pricenew': this.create.createTemp.pricenew,
- 'wagonnumber': this.create.createTemp.wagonnumber
- }}
- if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
- this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
- 'operateweight': this.create.createTemp.operateweight,
- 'pastureid': this.create.createTemp.pastureid,
- 'feedid': this.create.createTemp.feedid,
- 'fname': this.create.createTemp.fname,
- 'pcpde': this.create.createTemp.pcpde,
- 'stockweight': this.create.createTemp.startweight,
- 'price': this.create.createTemp.pricenew
- }}
- }
- console.log('点击了新增入库单保存', this.requestParam)
- ExecDataByConfig(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- failproccess(response, this.$notify)
- } else {
- this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
- this.create.dialogFormVisible = false
- this.getList()
- }
- })
- })
- }
- })
- },
- handleSee(row) {
- console.log('点击了查看')
- this.$nextTick(() => {
- this.$refs.createTemp.resetFields()
- })
- this.create.dialogStatus = 'see'
- this.create.dialogFormVisible = true
- this.create.createTemp = Object.assign({}, row)
- },
- handleInitial() {
- console.log('点击了初始化库存')
- this.initial.dialogStatus = 'initial'
- this.initial.dialogFormVisible = true
- this.getInitialList()
- },
- getInitialList() {
- this.initial.listLoading = true
- GetDataByName(this.initial.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- this.initial.list = response.data.list
- this.initial.pageNum = response.data.pageNum
- this.initial.pageSize = response.data.pageSize
- this.initial.total = response.data.total
- } else {
- this.initial.list = []
- }
- setTimeout(() => {
- this.initial.listLoading = false
- }, 100)
- })
- },
- handleInitialExport() {
- console.log('点击了初始化库存导出')
- const ExcelDatas = [
- {
- tHeader: ['饲料名称', '库存重量'],
- filterVal: ['fname', 'stockweight'],
- tableDatas: this.initial.list,
- sheetName: '初始化库存'
- }
- ]
- json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
- },
- async handleInitialImport(eve) {
- const file = eve.raw
- if (!file) return
- let reader = await upload(file)
- const worker = xlsx.read(reader, { type: 'binary' })
- // 将返回的数据转换为json对象的数据
- reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
- console.log(reader)
- const arr = []
- reader.forEach(item => {
- const obj = {}
- for (const key in this.initial.character) {
- if (!this.initial.character.hasOwnProperty(key)) break
- let v = this.initial.character[key]
- const text = v.text
- const type = v.type
- v = item[text] || ''
- type === 'string' ? (v = String(v)) : null
- type === 'number' ? (v = Number(v)) : null
- obj[key] = v
- }
- arr.push(obj)
- })
- console.log('导入处理后数据', arr)
- var sum = 0
- for (let i = 0; i < this.initial.list.length; i++) {
- for (let j = 0; j < arr.length; j++) {
- if (this.initial.list[i].fname == arr[j].fname) {
- this.initial.list[i].stockweight = arr[j].stockweight
- sum++
- arr.splice(j, 1)
- }
- }
- }
- console.log(arr)
- for (let i = 0; i < arr.length; i++) {
- this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
- }
- console.log(sum)
- this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
- this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
- if (arr.length > 0) {
- const ExcelDatas1 = [
- {
- tHeader: ['饲料名称', '库存重量', '报错信息'],
- filterVal: ['fname', 'stockweight', 'msg'],
- tableDatas: arr,
- sheetName: 'ExcelDatas1'
- }
- ]
- json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
- }
- },
- initialData() {
- console.log('点击了初始化库存保存')
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- var rulesStockweight = /^\d+(\.\d{1,2})?$/
- for (let i = 0; i < this.initial.list.length; i++) {
- if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
- this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
- return false
- }
- }
- this.requestParam.common = { 'returnmap': '0' }
- this.requestParam.data = []
- this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
- 'pastureid': Cookies.get('pastureid')
- }}
- this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
- this.requestParam.data[1].children = []
- this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
- pastureid: '@insertSpotList.pastureid',
- feedid: '@insertSpotList.feedid',
- fname: '@insertSpotList.fname',
- pcpde: '@insertSpotList.pcpde',
- stockweight: '@insertSpotList.stockweight',
- price: '@insertSpotList.price'
- }}
- ExecDataByConfig(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- failproccess(response, this.$notify)
- } else {
- this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
- this.create.dialogFormVisible = false
- this.getList()
- }
- })
- },
- // 导出
- handleExport(item) {
- if (item == 1) {
- console.log('点击了导出模板')
- var excelDatas = [
- {
- tHeader: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
- filterVal: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
- tableDatas: this.download.list,
- sheetName: 'Sheet1'
- }
- ]
- json2excel(excelDatas, '入库管理模板', true, 'xlsx')
- } else {
- console.log('点击了导出数据')
- this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
- if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
- this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
- this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
- } else {
- this.download.getdataListParm.parammaps.inputDatetime = ''
- this.download.getdataListParm.parammaps.startTime = ''
- this.download.getdataListParm.parammaps.stopTime = ''
- }
- 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)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
- filterVal: ['laiddate', 'wagonnumber', 'feedname', 'providername', 'contractcode', 'operateweight', 'pricenew', 'sumprice', 'grossweight', 'tareweight', 'licence', 'pcpde', 'createemp', 'createdate', 'remark'],
- tableDatas: this.download.list,
- sheetName: 'Sheet1'
- }
- ]
- json2excel(excelDatas, '入库管理', true, 'xlsx')
- })
- }
- },
- 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 = [
- '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '错误信息'
- ]
- const filterVal = [
- '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '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]
- }
- })
- )
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .search{margin-top:10px;}
- .table{margin-top:10px;}
- </style>
|