生产管理
This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| <!-- | ||||
|  * @Author: zhp | ||||
|  * @Date: 2024-04-15 10:49:13 | ||||
|  * @LastEditTime: 2024-05-22 15:25:11 | ||||
|  * @LastEditTime: 2024-05-31 19:14:05 | ||||
|  * @LastEditors: DY | ||||
|  * @Description: | ||||
| --> | ||||
| @@ -10,17 +10,17 @@ | ||||
|     <div class="app-container" style="padding: 16px 24px 0;height: auto; flex-grow: 1;"> | ||||
|       <el-form :model="listQuery" :inline="true" ref="dataForm" class="blueTip"> | ||||
|         <el-form-item label="时间维度" prop="date"> | ||||
|           <el-select size="small" clearable v-model="listQuery.date" placeholder="请选择"> | ||||
|           <el-select size="small" clearable v-model="listQuery.mode" placeholder="请选择"> | ||||
|             <el-option v-for="item in timeList" :key="item.value" :label="item.label" :value="item.value"> | ||||
|             </el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item v-show="listQuery.date === 0 || listQuery.date === ''" label="时间范围" prop="reportTime"> | ||||
|         <el-form-item v-show="listQuery.mode === 0 || listQuery.mode === ''" label="时间范围" prop="reportTime"> | ||||
|           <el-date-picker size="small" clearable v-model="listQuery.reportTime" type="datetimerange" range-separator="至" | ||||
|             start-placeholder="开始日期" value-format="timestamp" @change="changeDayTime" end-placeholder="结束日期"> | ||||
|             start-placeholder="开始日期" value-format="timestamp" format="yyyy-MM-dd" @change="changeDayTime" end-placeholder="结束日期"> | ||||
|           </el-date-picker> | ||||
|         </el-form-item> | ||||
|         <el-form-item v-show="listQuery.date === 1" label="时间范围" prop="reportTime"> | ||||
|         <el-form-item v-show="listQuery.mode === 1" label="时间范围" prop="reportTime"> | ||||
|           <el-date-picker size="small" clearable v-model="listQuery.start" type="week" format="yyyy 第 WW 周" placeholder="选择周" | ||||
|             style="width: 180px" @change="onValueChange"> | ||||
|           </el-date-picker> | ||||
| @@ -32,12 +32,12 @@ | ||||
|             {{ date1 }} 至 {{ date2 }},共 {{ weekNum }} 周 | ||||
|           </span> | ||||
|         </el-form-item> | ||||
|         <el-form-item v-show="listQuery.date === 2" label="时间范围" prop="reportTime"> | ||||
|         <el-form-item v-show="listQuery.mode === 2" label="时间范围" prop="reportTime"> | ||||
|           <el-date-picker size="small" clearable v-model="listQuery.reportTime" type="monthrange" value-format="timestamp" range-separator="至" | ||||
|             start-placeholder="开始月份" end-placeholder="结束月份" @change="changeTime"> | ||||
|           </el-date-picker> | ||||
|         </el-form-item> | ||||
|         <el-form-item v-show="listQuery.date === 3" label="时间范围" prop="reportTime"> | ||||
|         <el-form-item v-show="listQuery.mode === 3" label="时间范围" prop="reportTime"> | ||||
|           <el-date-picker size="small" clearable v-model="listQuery.start" format="yyyy-MM-dd" value-format="timestamp" type="year" | ||||
|             placeholder="开始时间"> | ||||
|           </el-date-picker> | ||||
| @@ -48,7 +48,7 @@ | ||||
|         </el-form-item> | ||||
|         <el-form-item label="工厂名称" prop="factorys"> | ||||
|           <el-select size="small" clearable v-model="listQuery.factorys" placeholder="请选择工厂名称" multiple > | ||||
|             <el-option v-for="item in factoryList" :key="item.id" :label="item.name" :value="item.id"> | ||||
|             <el-option v-for="item in factoryArray" :key="item.id" :label="item.name" :value="item.id"> | ||||
|             </el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
| @@ -59,7 +59,7 @@ | ||||
|           </el-select> | ||||
|         </el-form-item> --> | ||||
|         <el-form-item label="玻璃类型" prop="type"> | ||||
|           <el-select size="small" clearable v-model="listQuery.type" placeholder="请选择玻璃类型"> | ||||
|           <el-select size="small" clearable v-model="listQuery.type" multiple placeholder="请选择玻璃类型"> | ||||
|             <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"> | ||||
|             </el-option> | ||||
|           </el-select> | ||||
| @@ -94,7 +94,7 @@ | ||||
|         @pagination="getDataList" | ||||
|       /> | ||||
|     </div> | ||||
|     <add-or-update v-if="detailOrUpdateVisible" ref="detailOrUpdate" :date="listQuery.date" @refreshDataList="successSubmit" @destroy="detailOrUpdateVisible = false" /> | ||||
|     <add-or-update v-if="detailOrUpdateVisible" ref="detailOrUpdate" :date="listQuery.mode" @refreshDataList="successSubmit" @destroy="detailOrUpdateVisible = false" /> | ||||
|     <!-- <inputTable :date="date" :data="tableData" :time="[startTimeStamp, endTimeStamp]" :sum="all" | ||||
|       :type="listQuery.reportType" @refreshDataList="getDataList" /> --> | ||||
|     <!-- <pagination | ||||
| @@ -107,27 +107,29 @@ | ||||
|  | ||||
| <script> | ||||
| // import { parseTime } from '../../core/mixins/code-filter'; | ||||
| import { getProduceDataPage, exportOutPutExcel } from '@/api/produceData'; | ||||
| import { getProduceDataPage, prodOutputDataList, exportOutPutExcel } from '@/api/produceData'; | ||||
| // import inputTable from './inputTable.vue'; | ||||
| import lineChart from './lineChart'; | ||||
| import moment from 'moment' | ||||
| import ButtonNav from '@/components/ButtonNav' | ||||
| import basicPage from '@/mixins/basic-page' | ||||
| import AddOrUpdate from './add-or-updata'; | ||||
| import AddOrUpdate from './add-or-updata' | ||||
| import { factoryList, factoryArray, factoryArray1 } from "@/utils/constants"; | ||||
|  | ||||
| // import FileSaver from 'file-saver' | ||||
| // import * as XLSX from 'xlsx' | ||||
| export default { | ||||
|   components: { lineChart, ButtonNav, AddOrUpdate }, | ||||
|   mixins: [basicPage], | ||||
| 	data() { | ||||
|     return { | ||||
|       factoryList, | ||||
|       factoryArray, | ||||
|       factoryArray1, | ||||
|       listQuery: { | ||||
|         size: 20, | ||||
|         current: 1, | ||||
|         factorys: [], | ||||
|         factorys: undefined, | ||||
|         total: 0, | ||||
|         date: 1, | ||||
|         mode: 0, | ||||
|         type:undefined, | ||||
|         // reportType: 2, | ||||
|         beginTime: undefined, | ||||
| @@ -163,31 +165,6 @@ export default { | ||||
|           id: 2, | ||||
|         }, | ||||
|       ], | ||||
|       // weekNum: undefined, | ||||
|       dataList: [ | ||||
|         { | ||||
|           id:'first', | ||||
|         }, | ||||
|          { | ||||
|           id: 'second', | ||||
|         }, | ||||
|          { | ||||
|           id: 'third', | ||||
|         }, | ||||
|          { | ||||
|           id: 'fourth', | ||||
|         }, | ||||
|          { | ||||
|           id: 'fifth', | ||||
|         }, | ||||
|          { | ||||
|           id: 'sixth', | ||||
|         }, | ||||
|       ], | ||||
| 			urlOptions: { | ||||
| 				// getDataListURL: getGlassPage, | ||||
| 				// exportURL: exportGlasscExcel | ||||
|       }, | ||||
|       formConfig: [ | ||||
|         { | ||||
|           type: 'title', | ||||
| @@ -218,36 +195,6 @@ export default { | ||||
|           label: '年' | ||||
|         } | ||||
|       ], | ||||
|       factoryList: [ | ||||
|         { | ||||
|           name: '瑞昌中建材光电材料有限公司', | ||||
|           id: 0 | ||||
|         }, | ||||
|         { | ||||
|           name: '邯郸中建材光电材料有限公司', | ||||
|           id: 1 | ||||
|         }, | ||||
|         { | ||||
|           name: '中建材株洲光电材料有限公司', | ||||
|           id: 2 | ||||
|         }, | ||||
|         { | ||||
|           name:  '佳木斯中建材光电材料有限公司', | ||||
|           id: 3 | ||||
|         }, | ||||
|         { | ||||
|           name:  '成都中建材光电材料有限公司', | ||||
|           id: 4 | ||||
|         }, | ||||
|         { | ||||
|           name:  '凯盛光伏材料有限公司', | ||||
|           id: 5 | ||||
|         }, | ||||
|         { | ||||
|           name:  '蚌埠兴科玻璃有限公司', | ||||
|           id: 6 | ||||
|         } | ||||
|       ], | ||||
|       tableProps: [ | ||||
|         { | ||||
|           prop: 'tableTime', | ||||
| @@ -258,7 +205,7 @@ export default { | ||||
|         { | ||||
|           prop: 'factory', | ||||
|           label: '工厂名称', | ||||
|           filter: (val) => ['瑞昌中建材光电材料有限公司', '邯郸中建材光电材料有限公司', '中建材株洲光电材料有限公司', '佳木斯中建材光电材料有限公司', '成都中建材光电材料有限公司', '凯盛光伏材料有限公司', '蚌埠兴科玻璃有限公司'][val], | ||||
|           filter: (val) => factoryList[val], | ||||
|           minWidth: 200, | ||||
|           showOverflowtooltip: true | ||||
|         }, | ||||
| @@ -282,21 +229,30 @@ export default { | ||||
|         { | ||||
|           prop: 'yieldRate', | ||||
|           label: '良品率%', | ||||
|           filter: (val) => val + '%' | ||||
|         }, | ||||
|       ], | ||||
|       tableData: [], | ||||
|       xAxis: [] | ||||
|       lineData: [], | ||||
|       chart: null, | ||||
|       seriesList: [] | ||||
| 			// proLineList: [], | ||||
| 			// all: {} | ||||
| 		}; | ||||
| 		};  | ||||
|   }, | ||||
|   computed: { | ||||
|     weekNum() { | ||||
|       return Math.round((this.listQuery.end - this.listQuery.start) / (24 * 60 * 60 * 1000 * 7)) + 1 | ||||
|     }, | ||||
|   }, | ||||
|   created() { | ||||
|     const today = new Date() | ||||
|     const sevenDaysAgo = new Date(today.getTime() - (7 * 24 * 60 * 60 * 1000)) | ||||
|     this.listQuery.beginTime = sevenDaysAgo.getTime() | ||||
|     this.listQuery.endTime = today.getTime() | ||||
|     this.listQuery.reportTime = [this.listQuery.beginTime, this.listQuery.endTime] | ||||
| 	}, | ||||
| 	mounted() { | ||||
|     this.getDataList() | ||||
| 	}, | ||||
|   methods: { | ||||
|     otherMethods(val) { | ||||
| @@ -306,9 +262,6 @@ export default { | ||||
|         this.$refs.detailOrUpdate.init(val.data.id); | ||||
|       }); | ||||
|     }, | ||||
|     // buttonClick() { | ||||
|  | ||||
|     // }, | ||||
|     getYear(e) { | ||||
|       if (this.listQuery.end - this.listQuery.start > 10*365*24*60*60*1000) { | ||||
|         this.$message({ | ||||
| @@ -380,75 +333,100 @@ export default { | ||||
|         console.log(this.listQuery.reportTime[0]) | ||||
|       } | ||||
|     }, | ||||
|     // async getDict() { | ||||
| 			// 产线列表 | ||||
| 			// const res = await getCorePLList(); | ||||
| 			// this.proLineList = res.data; | ||||
| 		// }, | ||||
|     // 获取数据列表 | ||||
|     multipliedByHundred(str) { | ||||
|       console.log(str); | ||||
|       // console.log(str) | ||||
|       if ( str != 0) { | ||||
|         let floatVal = parseFloat(str); | ||||
|         if (isNaN(floatVal)) { | ||||
|           return 0; | ||||
|         } | ||||
|         floatVal = Math.round(str * 10000) / 100; | ||||
|         let strVal = floatVal.toString(); | ||||
|         let searchVal = strVal.indexOf('.'); | ||||
|         if (searchVal < 0) { | ||||
|           searchVal = strVal.length; | ||||
|           strVal += '.'; | ||||
|         } | ||||
|         while (strVal.length <= searchVal + 2) { | ||||
|           strVal += '0'; | ||||
|         } | ||||
|         return parseFloat(strVal); | ||||
|       } | ||||
|  | ||||
|     }, | ||||
|     async getDataList() { | ||||
|       const res = await getProduceDataPage(this.listQuery) | ||||
|       console.log(res) | ||||
|       this.tableData = res.data.records | ||||
|       this.tableData.forEach(item => { | ||||
|         item.tableTime = item?.reportDate?.length > 0 ? item.reportDate[0] + '-' + item.reportDate[1] + '-' + item.reportDate[2] : '--' | ||||
|       // const res = await getProduceDataPage(this.listQuery) | ||||
|       // console.log(res) | ||||
|       // if (res.code === 0) { | ||||
|       //   this.tableData = res.data.records | ||||
|       //   this.listQuery.total = res.data.total | ||||
|       //   if (this.listQuery.total > 0) { | ||||
|       //     this.tableData.forEach(item => { | ||||
|       //       item.tableTime = item?.reportDate?.length > 0 ? item.reportDate[0] + '-' + item.reportDate[1] + '-' + item.reportDate[2] : '--' | ||||
|       //     }) | ||||
|       //   } | ||||
|       // } | ||||
|  | ||||
|       // 图表 | ||||
|       await prodOutputDataList({ | ||||
|         current: 1, | ||||
|         size: 99, | ||||
|         beginTime: this.listQuery.beginTime, | ||||
|         endTime: this.listQuery.endTime, | ||||
|         factorys: this.listQuery.factorys, | ||||
|         mode: this.listQuery.mode, | ||||
|         type: this.listQuery.type | ||||
|       }).then(resp => { | ||||
|         console.log('Aaa', resp.data) | ||||
|         this.lineData = resp?.data || [] | ||||
|         if (this.lineData.length > 0) { | ||||
|           this.buildChart(this.lineData) | ||||
|         } | ||||
|       }) | ||||
|       this.listQuery.total = res.data.total | ||||
|       this.buildChart(this.tableData) | ||||
|       // this.buildChart(this.tableData) | ||||
|     }, | ||||
|     buildChart(list) { | ||||
|       const chartList = Object.groupBy(list, (item) => item.tableTime) | ||||
|       this.xAxis = [] | ||||
|       this.seriesList = [] | ||||
|       for (const keyIndex in chartList) { | ||||
|         // X坐标轴数据 | ||||
|         this.xAxis.push(keyIndex) | ||||
|       } | ||||
|       let temp = [] | ||||
|       let xAxisData = [] | ||||
|       list.forEach(item => { | ||||
|         temp.push(item.groupTime) | ||||
|       }) | ||||
|       // x轴数据 | ||||
|       xAxisData = Array.from(new Set(temp)) | ||||
|        | ||||
|       // y轴数据 | ||||
|       for (const y of this.factoryList) { | ||||
|         // y: {name: , id: } | ||||
|         const seriesItem = { | ||||
|           name: y.name, | ||||
|       for (const y of this.factoryArray1) { | ||||
|         for (const type of this.typeList) { | ||||
|           const seriesItem = { | ||||
|             name: y.name, | ||||
|             record: type.name, | ||||
|             type: 'bar', | ||||
|             emphasis: { | ||||
|               focus: 'series' | ||||
|             }, | ||||
|           data: Array(this.xAxis.length).fill(0) | ||||
|         } | ||||
|         for (const a in chartList) { | ||||
|           for (const z of chartList[a]) { | ||||
|             this.xAxis.forEach((item, index) => { | ||||
|               if (z.factory === y.id && a === item) { | ||||
|                 seriesItem.data[index] = z.goodNumber | ||||
|             data: Array(xAxisData.length).fill(0) | ||||
|           } | ||||
|           list.forEach(data => { | ||||
|             xAxisData.forEach((x, index) => { | ||||
|               if (x === data.groupTime && y.id === data.factory && type.id === data.glassType) { | ||||
|                 seriesItem.data[index] = data.goodNumber | ||||
|               } | ||||
|             }) | ||||
|           } | ||||
|           }) | ||||
|           this.seriesList.push(seriesItem) | ||||
|         } | ||||
|         this.seriesList.push(seriesItem) | ||||
|       } | ||||
|       this.$refs.lineChart.initChart(this.xAxis, this.seriesList) | ||||
|       console.log('啊啊', this.seriesList) | ||||
|       this.$refs.lineChart.initChart(xAxisData, this.seriesList) | ||||
|       // const chartList = Object.groupBy(list, (item) => item.tableTime) | ||||
|       // this.xAxis = [] | ||||
|       // this.seriesList = [] | ||||
|       // for (const keyIndex in chartList) { | ||||
|       //   // X坐标轴数据 | ||||
|       //   this.xAxis.push(keyIndex) | ||||
|       // } | ||||
|       // // y轴数据 | ||||
|       // for (const y of this.factoryArray) { | ||||
|       //   // y: {name: , id: } | ||||
|       //   const seriesItem = { | ||||
|       //     name: y.name, | ||||
|       //       type: 'bar', | ||||
|       //       emphasis: { | ||||
|       //         focus: 'series' | ||||
|       //       }, | ||||
|       //     data: Array(this.xAxis.length).fill(0) | ||||
|       //   } | ||||
|       //   for (const a in chartList) { | ||||
|       //     for (const z of chartList[a]) { | ||||
|       //       this.xAxis.forEach((item, index) => { | ||||
|       //         if (z.factory === y.id && a === item) { | ||||
|       //           seriesItem.data[index] = z.goodNumber | ||||
|       //         } | ||||
|       //       }) | ||||
|       //     } | ||||
|       //   } | ||||
|       //   this.seriesList.push(seriesItem) | ||||
|       // } | ||||
|       // this.$refs.lineChart.initChart(this.xAxis, this.seriesList) | ||||
|     }, | ||||
| 		buttonClick(val) { | ||||
| 			this.listQuery.reportTime = val.reportTime ? val.reportTime : undefined; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user