1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345 |
- <template>
- <div class="app-container">
- <!-- 配方模板表 -->
- <div ref="template" class="template">
- <div class="recipeTemplate">
- <p>日执行计划</p>
- </div>
- <div class="operation" style="margin-bottom: 10px;">
- <el-button class="success" @click="handleCreate">新生成</el-button>
- <el-button class="success" @click="handleRevisePlan">修改计划</el-button>
- <el-button class="success" @click="handleCopy">复制计划</el-button>
- <el-button v-if="isOrder" class="success" @click="handleChangeOrder">更改顺序</el-button>
- <div v-else style="margin-left: 10px;display: inline-block;">
- <el-button class="success" @click="saveChangeOrder">保存</el-button>
- <el-button class="success" @click="cancelChangeOrder">取消</el-button>
- </div>
- </div>
- <div class="search">
- <el-date-picker v-model="table.getdataListParm.parammaps.mydate" type="date" placeholder="选择日期" style="width: 150px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :clearable="false" @change="changeDate" />
- <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.lpplantype" filterable placeholder="计划类型" class="filter-item" clearable style="width: 120px;" @change="changePlanType">
- <el-option v-for="item in planTypeList" :key="item.value" :label="item.lable" :value="item.value" />
- </el-select>
- <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable @change="changeFrequency">
- <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="打印类型" class="filter-item" clearable style="width: 120px;">
- <el-option v-for="item in printingTypeList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="计划维度" class="filter-item" style="width: 120px;" clearable>
- <el-option v-for="item in planningDimensionList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="导出类型" class="filter-item" style="width: 120px;" clearable>
- <el-option v-for="item in exportTypeList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-button class="export" @click="handleExport">导出</el-button>
- </div>
- <!-- 日执行计划 -->
- <div class="table">
- <el-table
- id="table1"
- :key="table.tableKey"
- v-loading="table.listLoading"
- element-loading-text="给我一点时间"
- :data="table.list"
- border
- fit
- highlight-current-row
- style="width: 98%;"
- row-key="sort"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- @row-click="tableRowClick"
- >
- <el-table-column label="序号" align="center" prop="sort" width="50px" />
- <el-table-column label="计划名称" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.projname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="计划类型" prop="weight" min-width="130px" align="center" :formatter="lpplantype" />
- <el-table-column label="TMR编号" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.tmrtname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="驾驶员" min-width="90px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.driver }}</span>
- </template>
- </el-table-column>
- <el-table-column label="已执行" min-width="90px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.havebutton == 0">否</span>
- <span v-else>是</span>
- </template>
- </el-table-column>
- <el-table-column label="班次" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.times }}</span>
- </template>
- </el-table-column>
- <el-table-column label="理论量" min-width="110px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.lweight }}</span>
- </template>
- </el-table-column>
- <el-table-column label="时间" min-width="180px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.plantime }}</span>
- </template>
- </el-table-column>
- <el-table-column label="发料位" min-width="180px" align="left">
- <template slot-scope="scope">
- <span>{{ scope.row.barnames }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <!-- 预混料 -->
- <div v-if="table3.getdataListParm.parammaps.lpplantype == 4" class="content">
- <div class="table2">
- <div class="contentOperation">
- <p>计划内容<br>操作详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table2.tableKey"
- v-loading="table2.listLoading"
- element-loading-text="给我一点时间"
- :data="table2.list"
- fit
- highlight-current-row
- style="width: 100%;"
- height="450"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- <!-- 撒料 -->
- <div v-if="table3.getdataListParm.parammaps.lpplantype == 0" class="content">
- <div class="table2">
- <div class="contentOperation">
- <p>计划内容<br>操作详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table2.tableKey"
- v-loading="table2.listLoading"
- element-loading-text="给我一点时间"
- :data="table2.list"
- fit
- highlight-current-row
- style="width: 100%;"
- height="450"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <div class="table3">
- <div class="contentOperation">
- <p>计划内容<br>栏舍详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table3.tableKey"
- v-loading="table3.listLoading"
- element-loading-text="给我一点时间"
- :data="table3.list"
- height="450"
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label=" 操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <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="设计重量(KG)" prop="weight" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- <!-- 剩料 -->
- <div v-if="table3.getdataListParm.parammaps.lpplantype == 3" class="content">
- <div class="table2">
- <div class="contentOperation">
- <p>计划内容<br>操作详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table2.tableKey"
- v-loading="table2.listLoading"
- element-loading-text="给我一点时间"
- :data="table2.list"
- fit
- highlight-current-row
- style="width: 100%;"
- height="450"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="取料栏舍" prop="fname" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="处理方式" prop="useinbar" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.useinbar }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <div class="table3">
- <div class="contentOperation">
- <p>计划内容<br>栏舍详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table3.tableKey"
- v-loading="table3.listLoading"
- element-loading-text="给我一点时间"
- :data="table3.list"
- height="450"
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="转投栏舍" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fname }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- <!-- 撒料计划-混料 -->
- <div v-if="table3.getdataListParm.parammaps.lpplantype == 1 || table3.getdataListParm.parammaps.lpplantype == 5" class="content">
- <div class="table2">
- <div class="contentOperation">
- <p>计划内容<br>操作详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table2.tableKey"
- v-loading="table2.listLoading"
- element-loading-text="给我一点时间"
- :data="table2.list"
- fit
- highlight-current-row
- style="width: 100%;"
- height="450"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <div class="table3">
- <div class="contentOperation">
- <p>计划内容<br>栏舍详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table3.tableKey"
- v-loading="table3.listLoading"
- element-loading-text="给我一点时间"
- :data="table3.list"
- height="450"
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label=" 操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <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="设计重量(KG)" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- <!-- 撒料计划-撒料 -->
- <div v-if="table3.getdataListParm.parammaps.lpplantype == 2" class="content">
- <div class="table3">
- <div class="contentOperation">
- <p>计划内容<br>栏舍详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table3.tableKey"
- v-loading="table3.listLoading"
- element-loading-text="给我一点时间"
- :data="table3.list"
- height="450"
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label=" 操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <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="设计重量(KG)" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <div class="table2">
- <div class="contentOperation">
- <p>计划内容<br>操作详情</p>
- </div>
- <div class="content-table">
- <el-table
- :key="table2.tableKey"
- v-loading="table2.listLoading"
- element-loading-text="给我一点时间"
- :data="table2.list"
- fit
- highlight-current-row
- style="width: 100%;"
- height="450"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable table-fixed"
- >
- <el-table-column label="操作序号" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="栏舍名称" prop="fname" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.fname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.weight }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- <!-- 新生成 -->
- <el-dialog :title="textMap[newGeneration.dialogStatus]" :destroy-on-close="true" :visible.sync="newGeneration.dialogFormVisible" :close-on-click-modal="false" width="50%">
- <div class="newGeneration">
- <el-form ref="temp" :rules="newGeneration.rules" :model="newGeneration.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
- <el-row v-if="newGeneration.dialogStatus== 'newGeneration'">
- <el-col :span="16">
- <el-form-item label="时间范围:" prop="inputDatetime">
- <el-date-picker v-model="newGeneration.temp.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;" :clearable="false" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row v-else>
- <el-col :span="16">
- <el-form-item label="时间范围:" prop="copyInputDatetime">
- <el-date-picker v-model="newGeneration.temp.copyInputDatetime" :picker-options="pickerOptions" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;" :clearable="false" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer" style="bottom:10px">
- <el-button class="cancelClose" @click="newGeneration.dialogFormVisible = false;getList()">取消</el-button>
- <el-button v-if="newGeneration.dialogStatus== 'newGeneration'" class="success" :disabled="isokDisable" @click="newGenerationData()">确认</el-button>
- <el-button v-else class="success" :disabled="isokDisable" @click="copyData()">确认</el-button>
- </div>
- </div>
- </el-dialog>
- <!-- 历史记录 -->
- <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
- <div class="historyRecord">
- <keep-alive>
- <component :is="historyRecord.myComponent" ref="historyRecord" />
- </keep-alive>
- </div>
- <div slot="footer" class="dialog-footer" style="bottom: 10px;">
- <el-button class="cancelClose" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
- </div>
- </el-dialog>
- <!-- 修改计划 -->
- <RevisePlan :show.sync="isShowDialog" :parent-active-name="activeName" :parent-date="parentDate" />
- </div>
- </template>
- <script>
- import { GetDataByName, GetDataByNames, ExecDataByConfig, PostDataByName } from '@/api/common'
- import RevisePlan from './revisePlan.vue'
- import { parseTime } from '@/utils/index.js'
- import Cookies from 'js-cookie'
- import Sortable from 'sortablejs'
- export default {
- name: 'DailyExecutionPlan',
- components: {
- RevisePlan
- },
- data() {
- return {
- requestParams: [
- // { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
- ],
- planTypeList: [{ lable: '预混计划', value: '4' }, { lable: '撒料计划', value: '0' }, { lable: '剩料计划', value: '3' }, { lable: '撒料计划-混料', value: '1' }, { lable: '撒料计划-撒料', value: '2' }], // 计划类型
- printingTypeList: [{ lable: '所有', value: '0' }, { lable: '精料', value: '1' }, { lable: '铲车', value: '2' }], // 打印类型
- frequencyList: [], // 班次
- planningDimensionList: [{ lable: '发料顺序', value: '0' }, { lable: 'TMR', value: '1' }], // 发料顺序
- exportTypeList: [{ lable: '投料简打', value: '0' }, { lable: '投料简打', value: '1' }], // 导出类型
- // 班次
- maxTime: {
- getMaxTimesParm: {
- name: 'getSysoptEnable',
- page: 1,
- offset: 1,
- pagecount: 1,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- inforname: 'times'
- }
- }
- },
- isOrder: true,
- table: {
- getdataListParm: {
- name: 'getDownloadedplanList',
- page: 1,
- offset: 1,
- pagecount: '',
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- barid: '',
- mydate: parseTime(new Date(), '{y}-{m}-{d}'),
- times: '',
- lpplantype: ''
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: false
- },
- // 计划内容操作详情
- table2: {
- getdataListParm: {
- name: 'getDownloadplandtl1ListV2',
- page: 1,
- offset: 1,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- date: '',
- id: ''
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: false
- },
- // 计划内容 舍栏详情
- table3: {
- getdataListParm: {
- name: 'getDownloadplandt2ListV2',
- page: 1,
- offset: 1,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- date: '',
- id: ''
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: false
- },
- // 新生成
- newGeneration: {
- dialogFormVisible: false,
- dialogStatus: '',
- getdataListParm: {
- name: 'checkLLPIsDistribution',
- page: 1,
- offset: 1,
- pagecount: 1,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid')
- }
- },
- temp: {},
- rules: {
- inputDatetime: [{ type: 'array', required: true, message: '必填', trigger: 'blur' }],
- copyInputDatetime: [{ type: 'array', required: true, message: '必填', trigger: 'blur' }]
- }
- },
- pickerMinDate: '',
- pickerOptions: {
- onPick: ({ maxDate, minDate }) => {
- this.pickerMinDate = minDate.getTime()
- if (maxDate) {
- this.pickerMinDate = ''
- }
- },
- disabledDate: (time) => {
- if (this.pickerMinDate !== '') {
- const one = 31 * 24 * 3600 * 1000
- const minTime = this.pickerMinDate
- const maxTime = this.pickerMinDate + one
- return time.getTime() < minTime || time.getTime() > maxTime - 8.64e7
- }
- return time.getTime() < Date.now() - 8.64e7
- }
- },
- historyRecord: {
- dialogFormVisible: false,
- dialogStatus: '',
- myComponent: null
- },
- textMap: {
- newGeneration: '新生成',
- historyRecord: '历史记录',
- revisePlan: '修改计划',
- copy: '复制计划'
- },
- isokDisable: false,
- requestParam: {},
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' },
- isShowDialog: false,
- activeName: '栏舍配方',
- parentDate: ''
- }
- },
- created() {
- this.parentDate = this.table.getdataListParm.parammaps.mydate
- console.log(this.parentDate, 'this.parentDate')
- this.getList()
- this.getDownList()
- this.getIsDisplay()
- },
- mounted() {
- this.table.getdataListParm.parammaps.mydate = parseTime(new Date(), '{y}-{m}-{d}')
- },
- methods: {
- getIsDisplay() {
- GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
- console.log(response.data.list[0].inforvalue)
- if (response.data.list[0].inforvalue == 1) {
- this.frequencyList = [{ id: '1', name: '第一班' }]
- } else if (response.data.list[0].inforvalue == 2) {
- this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
- } else if (response.data.list[0].inforvalue == 3) {
- this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
- } else if (response.data.list[0].inforvalue == 4) {
- this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
- }
- })
- },
- getDownList() {
- GetDataByNames(this.requestParams).then(response => {
- // this.livestockTypeList = response.data.getDictByName.list
- })
- },
- // -------------------日执行计划-----------------------------
- handleBefore() {
- if (this.table.getdataListParm.parammaps.mydate !== '' && this.table.getdataListParm.parammaps.mydate !== null) {
- this.table.getdataListParm.parammaps.mydate = new Date(this.table.getdataListParm.parammaps.mydate)
- var start = new Date(this.table.getdataListParm.parammaps.mydate.setDate(this.table.getdataListParm.parammaps.mydate.getDate() - 1))
- // var start = this.table.getdataListParm.parammaps.mydate - 1
- this.table.getdataListParm.parammaps.mydate = parseTime(start, '{y}-{m}-{d}')
- // this.$forceUpdate()
- this.getList()
- }
- },
- handleNext() {
- if (this.table.getdataListParm.parammaps.mydate !== '' && this.table.getdataListParm.parammaps.mydate !== null) {
- this.table.getdataListParm.parammaps.mydate = new Date(this.table.getdataListParm.parammaps.mydate)
- var stop = new Date(this.table.getdataListParm.parammaps.mydate.setDate(this.table.getdataListParm.parammaps.mydate.getDate() + 1))
- this.table.getdataListParm.parammaps.mydate = parseTime(stop, '{y}-{m}-{d}')
- this.getList()
- }
- },
- getList() {
- this.table.listLoading = true
- GetDataByName(this.table.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- // var obj = { 'id': '580999', 'havebutton': '0', 'lpplantype': 2, 'pid': '3283220207862547456', 'times': '第二班', 'projname': '2.666' }
- // response.data.list[6] = obj
- this.table.list = response.data.list
- this.table.pageNum = response.data.pageNum
- this.table.pageSize = response.data.pageSize
- this.table.total = response.data.total
- console.log('计划类型', response.data.list[0].lpplantype)
- if (response.data.list[0].lpplantype == 0) {
- // 撒料
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
- this.getList2()
- this.getList3()
- } else if (response.data.list[0].lpplantype == 1) {
- // 撒料计划-混料
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
- this.getList2()
- this.getList3()
- } else if (response.data.list[0].lpplantype == 2) {
- // 撒料计划-撒料
- this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
- this.getList2()
- this.getList3()
- } else if (response.data.list[0].lpplantype == 3) {
- // 剩料
- this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = 0
- this.table3.getdataListParm.parammaps.useinbartype = 1
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
- this.getList2()
- this.getList3()
- } else if (response.data.list[0].lpplantype == 4) {
- // 预混
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
- this.getList2()
- } else if (response.data.list[0].lpplantype == 5) {
- // 预称重计划
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.id = response.data.list[0].id
- this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
- this.getList2()
- this.getList3()
- }
- } else {
- this.table.list = []
- this.table3.getdataListParm.parammaps.lpplantype = ''
- this.table2.getdataListParm.parammaps.id = ''
- this.table3.getdataListParm.parammaps.id = ''
- // this.getList2()
- // this.getList3()
- this.table2.list = []
- this.table3.list = []
- }
- setTimeout(() => {
- this.table.listLoading = false
- }, 100)
- })
- },
- lpplantype: function(cellValue) {
- if (cellValue.lpplantype == 0) {
- return '撒料计划'
- } else if (cellValue.lpplantype == 1) {
- return '撒料计划-混料'
- } else if (cellValue.lpplantype == 2) {
- return '撒料计划-撒料'
- } else if (cellValue.lpplantype == 3) {
- return '剩料计划'
- } else if (cellValue.lpplantype == 4) {
- return '预混计划'
- } else if (cellValue.lpplantype == 5) {
- return '预称重计划'
- }
- },
- changeDate(val) {
- console.log('选择了日期', val)
- this.getList()
- this.getList2()
- this.getList3()
- this.parentDate = this.table.getdataListParm.parammaps.mydate
- console.log(this.parentDate, 'this.parentDate')
- },
- changePlanType(val) {
- console.log('选择了计划类型', val)
- this.getList()
- this.getList2()
- this.getList3()
- },
- changeFrequency(val) {
- console.log('选择了班次', val)
- this.getList()
- this.getList2()
- this.getList3()
- },
- // 日执行计划行点击
- tableRowClick(row, column, event) {
- console.log(row, column, event)
- console.log('点击计划类型', row.lpplantype)
- // 撒料计划0/撒料计划-混料1/撒料计划-撒料2/剩料计划3/预混计划4/预称重计划5
- if (row.lpplantype == 0) {
- // 撒料
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
- this.getList2()
- this.getList3()
- } else if (row.lpplantype == 1) {
- // 撒料计划-混料
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
- this.getList2()
- this.getList3()
- } else if (row.lpplantype == 2) {
- // 撒料计划-撒料
- this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
- this.getList2()
- this.getList3()
- console.log(this.table3.getdataListParm.parammaps.lpplantype)
- } else if (row.lpplantype == 3) {
- // 剩料
- this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = 0
- this.table3.getdataListParm.parammaps.useinbartype = 1
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
- this.getList2()
- this.getList3()
- } else if (row.lpplantype == 4) {
- // 预混
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
- this.getList2()
- } else if (row.lpplantype == 5) {
- // 预称重计划
- this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
- this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
- this.table2.getdataListParm.parammaps.useinbartype = ''
- this.table3.getdataListParm.parammaps.useinbartype = ''
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.table2.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.id = row.id
- this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
- this.getList2()
- this.getList3()
- }
- this.$forceUpdate()
- },
- // 计划内容操作详情
- getList2() {
- this.table2.listLoading = true
- this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- GetDataByName(this.table2.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- this.table2.list = response.data.list
- // 撒料计划0/撒料计划-混料1/撒料计划-撒料2/剩料计划3/预混计划4
- if (this.table3.getdataListParm.parammaps.lpplantype == 0 || this.table3.getdataListParm.parammaps.lpplantype == 1 || this.table3.getdataListParm.parammaps.lpplantype == 4) {
- const arr = []
- var a = 0
- let b = this.table2.list[0].sort
- let c = 0
- for (let i = 0; i < this.table2.list.length; i++) {
- if (b !== parseInt(this.table2.list[i].sort)) {
- b = this.table2.list[i].sort
- arr.push({ 'sort': '小计', 'weight': a.toFixed(2) })
- a = 0
- }
- a = a + parseFloat(this.table2.list[i].weight)
- c = c + parseFloat(this.table2.list[i].weight)
- arr.push(this.table2.list[i])
- }
- arr.push({ 'sort': '小计', 'weight': a })
- arr.push({ 'sort': '总计', 'weight': c.toFixed(2) })
- this.table2.list = arr
- }
- if (this.table3.getdataListParm.parammaps.lpplantype == 2) {
- const arr = []
- var aa = 0
- let bb = this.table2.list[0].sort
- let cc = 0
- for (let i = 0; i < this.table2.list.length; i++) {
- if (bb !== parseInt(this.table2.list[i].sort)) {
- bb = this.table2.list[i].sort
- aa = 0
- }
- aa = aa + parseFloat(this.table2.list[i].weight)
- cc = cc + parseFloat(this.table2.list[i].weight)
- arr.push(this.table2.list[i])
- }
- arr.push({ 'sort': '总计', 'weight': cc.toFixed(2) })
- this.table2.list = arr
- console.log('this.table2.list', this.table2.list)
- console.log(this.table3.getdataListParm.parammaps.lpplantype)
- }
- console.log(this.table2.list)
- this.table2.pageNum = response.data.pageNum
- this.table2.pageSize = response.data.pageSize
- this.table2.total = response.data.total
- } else {
- this.table2.list = []
- }
- setTimeout(() => {
- this.table2.listLoading = false
- }, 100)
- })
- },
- // 计划内容栏舍详情
- getList3() {
- this.table3.listLoading = true
- this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
- GetDataByName(this.table3.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- this.table3.list = response.data.list
- if (this.table3.getdataListParm.parammaps.lpplantype == 0) {
- const arr = []
- var a = 0
- let b = this.table3.list[0].sort
- let c = 0
- for (let i = 0; i < this.table3.list.length; i++) {
- if (b !== parseInt(this.table3.list[i].sort)) {
- b = this.table3.list[i].sort
- a = 0
- }
- a = a + parseFloat(this.table3.list[i].weight)
- c = c + parseFloat(this.table3.list[i].weight)
- arr.push(this.table3.list[i])
- }
- arr.push({ 'sort': '总计', 'weight': c.toFixed(2) })
- this.table3.list = arr
- }
- this.table3.pageNum = response.data.pageNum
- this.table3.pageSize = response.data.pageSize
- this.table3.total = response.data.total
- } else {
- this.table3.list = []
- }
- setTimeout(() => {
- this.table3.listLoading = false
- }, 100)
- })
- },
- // 新生成
- handleCreate() {
- console.log('点击了新生成')
- this.newGeneration.temp = {}
- this.newGeneration.dialogStatus = 'newGeneration'
- this.newGeneration.dialogFormVisible = true
- GetDataByName(this.newGeneration.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- if (response.data.list[0].vmsg == '存在未分配') {
- this.$message({ type: 'warning', message: '撒料计划中存在未分配完栏舍,建议及时进行分配', duration: 2000 })
- }
- }
- })
- },
- DateDiff(sDate1, sDate2) {
- console.log(sDate1, sDate2)
- var aDate, oDate1, oDate2, iDays
- aDate = sDate1.split('-')
- oDate1 = new Date(aDate[0], aDate[1], aDate[2]) // 转换为12-18-2006格式
- aDate = sDate2.split('-')
- oDate2 = new Date(aDate[0], aDate[1], aDate[2])
- iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) // 把相差的毫秒数转换为天数
- this.newGeneration.temp.days = parseInt(iDays) + 1
- return iDays
- },
- newGenerationData() {
- console.log('点击了新生成保存', this.newGeneration.temp)
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 5000)
- this.$refs['temp'].validate(valid => {
- if (valid) {
- this.newGeneration.temp.startTime = parseTime(this.newGeneration.temp.inputDatetime[0], '{y}-{m}-{d}')
- this.newGeneration.temp.stopTime = parseTime(this.newGeneration.temp.inputDatetime[1], '{y}-{m}-{d}')
- this.DateDiff(this.newGeneration.temp.stopTime, this.newGeneration.temp.startTime)
- this.requestParam = {}
- this.requestParam.common = { 'returnmap': '0' }
- this.requestParam.data = []
- this.requestParam.data[0] = { 'name': 'checkDLPIsStart', 'type': 'v', 'parammaps': {
- pastureid: Cookies.get('pastureid'),
- startTime: this.newGeneration.temp.startTime
- }}
- this.requestParam.data[1] = { 'name': 'checkPreMixStorage', 'type': 'e', 'parammaps': {
- pastureid: Cookies.get('pastureid'),
- days: this.newGeneration.temp.days
- }}
- this.requestParam.data[2] = { 'name': 'createdownloadedplan', 'type': 'e', 'parammaps': {
- pastureid: Cookies.get('pastureid'),
- startTime: this.newGeneration.temp.startTime,
- stopTime: this.newGeneration.temp.stopTime
- }}
- ExecDataByConfig(this.requestParam).then(response => {
- console.log('新生成保存发送参数', this.requestParam)
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
- this.newGeneration.dialogFormVisible = false
- this.getList()
- }
- })
- }
- })
- },
- // 修改计划
- handleRevisePlan(data) {
- console.log('点击了修改计划1', this.activeName)
- this.isShowDialog = true
- this.activeName = '栏舍配方'
- console.log('点击了修改计划2', this.activeName)
- },
- handleExport() {
- console.log('点击了导出')
- },
- rowDrop() {
- console.log(document.querySelector('#table1 .el-table__body-wrapper tbody'))
- const tbody = document.querySelector('#table1 .el-table__body-wrapper tbody')
- // this.sorTable()
- const that = this
- var sortable = Sortable.create(tbody, {
- disabled: that.dropState,
- onChoose({ newIndex, oldIndex }) {
- if (that.dropState == true || that.isOrder == true) {
- sortable.destroy()
- }
- },
- onEnd(evt) {
- var tableList = [...that.table.list] // 保留拖动前数据
- const targetRow = that.table.list.splice(evt.oldIndex, 1)[0] // 拖动数据
- const targetRow2 = that.table.list[evt.newIndex] // 拖动后下方数据
- const targetRow3 = that.table.list[evt.newIndex - 1] // 拖动后上方数据
- console.log(targetRow, 'targetRow')
- console.log(targetRow2, 'targetRow2')
- console.log(targetRow3, 'targetRow3')
- that.table.list.splice(evt.newIndex, 0, targetRow)
- // ==========
- // 已执行的计划不可拖动
- if (targetRow.havebutton == 1) {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '因已执行的计划不可调整顺序', duration: 2000 })
- return false
- }
- // 相同班次之间可以拖动
- if (targetRow2 !== undefined && targetRow3 !== undefined) {
- if (targetRow.times !== targetRow2.times && targetRow.times !== targetRow3.times) {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
- return false
- }
- } else if (targetRow2 !== undefined && targetRow3 == undefined) {
- if (targetRow.times !== targetRow2.times) {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
- return false
- }
- } else if (targetRow2 == undefined && targetRow3 !== undefined) {
- if (targetRow.times !== targetRow3.times) {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
- return false
- }
- }
- // 撒料计划0,
- // 撒料计划-混料1
- // 撒料计划-撒料2
- // 剩料计划3
- // 预混计划4
- // 预称重计划5
- if (targetRow.lpplantype == 1) { // 拖动数据为撒料计划-混料
- if (targetRow2 == undefined) {
- console.log('遍历有相同的pid,一起跟着拖动1')
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- } else {
- console.log('遍历有相同的pid,一起跟着拖动2')
- var pidArr = [] // pid相同的值
- var pidArr1 = [] //
- var index // 索引
- for (let i = 0; i < tableList.length; i++) {
- if (tableList[i].pid == targetRow.pid) {
- pidArr.push(tableList[i])
- } else {
- pidArr1.push(tableList[i])
- }
- }
- // 找到对应上方pid 的ID
- // 比如说id 580243 找到对应的索引
- for (let i = 0; i < pidArr1.length; i++) {
- if (pidArr1[i].id == targetRow3.id) {
- index = i
- }
- }
- pidArr1.splice(index + 1, 0, ...pidArr)
- console.log(pidArr1)
- that.$nextTick(() => {
- that.table.list = pidArr1
- })
- }
- } else if (targetRow.lpplantype == 5) {
- if (targetRow2 == undefined) {
- console.log('遍历有相同的pid,一起跟着拖动预称重1')
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- } else {
- console.log('遍历有相同的pid,一起跟着拖动预称重2')
- var pidArr = [] // pid相同的值
- var pidArr1 = [] //
- var index // 索引
- for (let i = 0; i < tableList.length; i++) {
- if (tableList[i].pid == targetRow.pid) {
- pidArr.push(tableList[i])
- } else {
- pidArr1.push(tableList[i])
- }
- }
- // 找到对应上方pid 的ID
- // 比如说id 580243 找到对应的索引
- for (let i = 0; i < pidArr1.length; i++) {
- if (pidArr1[i].id == targetRow3.id) {
- index = i
- }
- }
- pidArr1.splice(index + 1, 0, ...pidArr)
- that.$nextTick(() => {
- that.table.list = pidArr1
- })
- }
- } else if (targetRow.lpplantype == 2) { // 拖动数据为撒料计划-撒料
- if (targetRow2 == undefined) {
- if (targetRow3.pid !== targetRow.pid) {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
- return false
- }
- } else {
- if (targetRow2.lpplantype == 1 && (targetRow2.pid == targetRow.pid || targetRow2 == undefined)) {
- // 拖动数据下方为撒料计划-混料时且pid相同,不可拖动,提示
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至撒料计划-混料上方', duration: 2000 })
- return false
- } else if (targetRow.lpplantype == 2 && (targetRow2.pid == targetRow.pid || targetRow3.pid == targetRow.pid || targetRow2 == undefined || targetRow3 == undefined)) {
- console.log('正常拖动')
- } else {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
- return false
- }
- }
- } else if (targetRow.lpplantype == 0 || targetRow.lpplantype == 3 || targetRow.lpplantype == 4) {
- if (targetRow2.pid == targetRow3.pid) {
- that.$nextTick(() => {
- that.$set(that.table, 'list', tableList)
- })
- that.$message({ type: 'error', message: '不可拖动至撒料计划-撒料跟撒料计划-混料之间', duration: 2000 })
- return false
- }
- }
- }
- })
- },
- // 复制
- handleCopy() {
- this.newGeneration.temp = {}
- this.newGeneration.dialogStatus = 'copy'
- this.newGeneration.dialogFormVisible = true
- },
- copyData() {
- console.log(this.newGeneration.temp.copyInputDatetime)
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 5000)
- this.$refs['temp'].validate(valid => {
- if (valid) {
- this.requestParam.name = 'copydownloadedplan'
- this.requestParam.parammaps = {}
- this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
- this.requestParam.parammaps.date = this.table.getdataListParm.parammaps.mydate
- this.requestParam.parammaps.startTime = parseTime(this.newGeneration.temp.copyInputDatetime[0], '{y}-{m}-{d}')
- this.requestParam.parammaps.stopTime = parseTime(this.newGeneration.temp.copyInputDatetime[1], '{y}-{m}-{d}')
- PostDataByName(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- this.newGeneration.dialogFormVisible = false
- this.getList()
- }
- })
- }
- })
- },
- handleChangeOrder() {
- // 拖动顺序
- this.isOrder = false
- this.rowDrop()
- },
- saveChangeOrder() {
- // 保存顺序
- this.requestParam = {}
- this.requestParam.common = { 'returnmap': '0' }
- this.requestParam.data = []
- this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table.list }}
- this.requestParam.data[0].children = []
- this.requestParam.data[0].children[0] = { 'name': 'updatedownloadesort', 'type': 'e', 'parammaps': {
- id: '@insertSpotList.id',
- pastureid: '@insertSpotList.pastureid',
- sort: '@insertSpotList.sort'
- }}
- ExecDataByConfig(this.requestParam).then(response => {
- console.log('顺序切换保存发送参数', this.requestParam)
- if (response.msg === 'fail') {
- this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
- this.getList()
- this.isOrder = true
- }
- })
- },
- cancelChangeOrder() {
- // 取消顺序
- this.getList()
- this.isOrder = true
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .operation{margin-bottom:10px;}
- .search{margin-top:10px;}
- .table{margin-top:10px;}
- .template{
- background: #fff;
- position: relative;
- }
- .table2{
- float: left;width: 49%;margin-right: 1%;background: red;
- background: #fff;
- position: relative;
- .content-table{margin-top: 70px;}
- }
- .table3{
- float: left;
- width: 49%;
- background: #fff;
- position: relative;
- .content-table{margin-top: 70px;}
- }
- </style>
|