123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- <template>
- <div class="mainContentBox">
- <avue-crud ref="crudRef1" v-model:search="data1.search" :data="data1.data" :option="data1.option"
- v-model:page="data1.page" @row-save="createRow" @row-update="updateRow" @row-del="deleteRow"
- @search-change="searchChange" @search-reset="resetChange" @size-change="dataList" @current-change="dataList"
- @selection-change="selectionChange">
- <template #menu="{ row, index, type }">
- <el-button @click="ckickCell(row)" icon="el-icon-view" text type="primary">查看</el-button>
- </template>
- <template #header="">
- <div id="dailystoragecharts"></div>
- </template>
- <template #menu-right="{}">
- <el-button class="ml-3" @click="
- data1.Utils.exportData(
- '/api/v1/process/census/abnormalOperation/export'
- )
- ">
- <template #icon> <i-ep-download /> </template>导出
- </el-button>
- </template>
- </avue-crud>
- <el-dialog v-model="editDialog.visible" :title="editDialog.title" width="1200px"
- @close="editDialog.visible = false">
- <div class="mainContentBox">
- <div id="dailystoragecharts2"></div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { ref, getCurrentInstance } from "vue";
- import { useCrud } from "@/hooks/userCrud";
- import { useCommonStoreHook, useDictionaryStoreHook } from "@/store";
- import dictDataUtil from "@/common/configs/dictDataUtil";
- import editSkill from "@/views/base/skill/components/edit-skill.vue";
- import { getOperationList, getOperationInfo } from "@/api/report";
- import * as echarts from "echarts";
- // 数据字典相关
- const { dicts } = useDictionaryStoreHook();
- const editDialog = ref({ visible: false, title: "订单详情" });
- const charts = shallowRef(null);
- const charts2 = shallowRef(null);
- const chartsSearch = ref({});
- const key = ref(false);
- // const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
- // useCrud({
- // src: "/api/v1/process/census/completeOrder",
- // });
- // ;
- const data1 = ref(
- useCrud({
- src: "/api/v1/process/census/completeOperation",
- })
- );
- const data2 = ref(
- useCrud({
- src: "/api/v1/process/census/operationList",
- })
- );
- const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
- data1.value.Methords;
- const { selectionChange, multipleDelete } = data1.value.Methords;
- const chartsData1 = ref({});
- const chartsData2 = ref({});
- const chartSeriesData1 = ref([]);
- const labelOption = {
- show: false,
- position: "insideBottom",
- distance: 15,
- align: "left",
- verticalAlign: "middle",
- rotate: 90,
- formatter: "{c} {name|{a}}",
- fontSize: 24,
- rich: {
- name: {},
- },
- };
- const echartOption1 = ref({
- title: {
- text: "工序完成数量",
- },
- tooltip: {
- trigger: "axis",
- axisPointer: {
- type: "shadow",
- },
- },
- legend: {
- // data: chartsData.value.orderCodes,
- data: ["工序完成数量"],
- },
- xAxis: [
- {
- type: "value",
- },
- ],
- yAxis: [
- {
- type: "category",
- axisTick: { show: false },
- data: [],
- },
- ],
- // series: chartSeriesData1.value,
- series: [
- {
- name: "工序完成数量",
- type: "bar",
- barGap: 0,
- label: labelOption,
- emphasis: {
- focus: "series",
- },
- // data: chartsData1.value.total,
- },
- ],
- });
- const echartOption2 = ref({
- title: {
- text: "生产趋势图",
- },
- tooltip: {
- trigger: "axis",
- axisPointer: {
- type: "shadow",
- },
- },
- legend: {
- data: [],
- },
- xAxis: [
- {
- type: "category",
- axisTick: { show: false },
- data: [],
- },
- ],
- yAxis: [
- {
- type: "value",
- },
- ],
- toolbox: {
- feature: {
- saveAsImage: {},
- },
- },
- series: [
- {
- name: "工序完成数量",
- type: "line",
- barGap: 0,
- label: labelOption,
- emphasis: {
- focus: "series",
- },
- data: [],
- },
- ],
- });
- const ckickCell = (row) => {
- editDialog.value.visible = true;
- editDialog.value.title = row.orderName;
- nextTick(async () => {
- charts2.value = echarts.init(
- document.getElementById("dailystoragecharts2")
- );
- chartsSearch.value.operationCode = row.operationCode;
- chartsSearch.value.orderCode = row.orderCode;
- chartsSearch.value.searchTime = data1.value.search.searchTime;
- echartOption2.value.title.text = row.orderName + ": 生产趋势图";
- await setChartsData2();
- echartOption2.value.xAxis[0].data = chartsData2.value.dateList;
- echartOption2.value.series[0].data = chartsData2.value.total;
- charts2.value.setOption(echartOption2.value, true);
- });
- };
- const setChartsData1 = async () => {
- const { data } = await getOperationList({
- ...data1.value.search,
- pageSize: 99999,
- });
- chartsData1.value = data;
- };
- const setChartsData2 = async () => {
- const { data } = await getOperationInfo({
- ...chartsSearch.value,
- });
- chartsData2.value = data;
- };
- // 设置表格列或者其他自定义的option
- data1.value.option = Object.assign(data1.value.option, {
- selection: false,
- menu: true,
- menuWidth: 100,
- addBtn: false,
- filterBtn: false,
- searchShowBtn: false,
- columnBtn: false,
- gridBtn: false,
- editBtn: false,
- viewBtn: false,
- delBtn: false,
- column: [
- {
- label: "日期范围",
- prop: "searchTime",
- search: true,
- hide: true,
- type: "date",
- format: "YYYY-MM-DD",
- valueFormat: "YYYY-MM-DD",
- searchRange: true,
- startPlaceholder: "开始日期",
- endPlaceholder: "结束日期",
- },
- {
- label: "订单编码",
- prop: "orderCode",
- overHidden: true,
- search: true,
- editDisabled: true,
- hide: true,
- },
- {
- label: "订单名称",
- prop: "orderName",
- overHidden: true,
- search: true,
- editDisabled: true,
- hide: true,
- },
- {
- label: "项目编码",
- prop: "projectCode",
- overHidden: true,
- search: true,
- editDisabled: true,
- hide: true,
- },
- {
- label: "产品规格",
- prop: "materialModel",
- width: 140,
- overHidden: true,
- search: true,
- editDisabled: true,
- hide: true,
- },
- {
- label: "订单名称",
- prop: "orderName",
- search: false,
- },
- {
- label: "订单编码",
- prop: "orderCode",
- search: false,
- },
- {
- label: "项目编码",
- prop: "projectCode",
- search: false,
- },
- {
- label: "物料编码",
- prop: "materialCode",
- search: false,
- },
- {
- label: "物料名称",
- prop: "materialName",
- search: false,
- },
- {
- label: "物料规格",
- prop: "materialModel",
- search: false,
- },
- {
- label: "工序编码",
- prop: "operationCode",
- search: false,
- },
- {
- label: "工序名称",
- prop: "operationName",
- search: false,
- },
- {
- label: "完工日期",
- prop: "realEndWhen",
- search: false,
- },
- {
- label: "总完工数量",
- prop: "total",
- search: false,
- },
- ],
- });
- const getCurrentMonthStartAndEndDates = () => {
- // 获取当前日期
- let now = new Date();
- // 获取当前月份的第一天
- let startDate = new Date(now.getFullYear(), now.getMonth(), 1);
- // 获取当前月份的最后一天
- let endDate = new Date(now.getFullYear(), now.getMonth() + 1, 0);
- // 格式化日期为'YYYY-MM-DD'格式
- function formatDate(date) {
- let year = date.getFullYear();
- let month = String(date.getMonth() + 1).padStart(2, "0");
- let day = String(date.getDate()).padStart(2, "0");
- return `${year}-${month}-${day}`;
- }
- // 返回包含开始和结束日期的数组
- return [formatDate(startDate), formatDate(endDate)];
- };
- //设置搜索条件中的时间范围为默认此月
- const setTime = () => {
- data1.value.search.searchTime = getCurrentMonthStartAndEndDates();
- };
- onMounted(async () => {
- setTime();
- charts.value = echarts.init(document.getElementById("dailystoragecharts"));
- dataList();
- await setChartsData1();
- echartOption1.value.yAxis[0].data = chartsData1.value.operationList;
- echartOption1.value.series[0].data = chartsData1.value.total;
- charts.value.setOption(echartOption1.value, true);
- });
- </script>
- <style lang="scss" scoped>
- :deep(.avue-crud__left) {
- width: 100%;
- }
- #dailystoragecharts {
- width: 100%;
- height: 400px;
- border: 1px solid #ccc;
- }
- #dailystoragecharts2 {
- width: 100%;
- height: 400px;
- border: 1px solid #ccc;
- }
- </style>
|