index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud ref="crudRef1" v-model:search="data1.search" :data="data1.data" :option="data1.option"
  4. v-model:page="data1.page" @row-save="createRow" @row-update="updateRow" @row-del="deleteRow"
  5. @search-change="searchChange" @search-reset="resetChange" @size-change="dataList" @current-change="dataList"
  6. @selection-change="selectionChange">
  7. <template #menu="{ row, index, type }">
  8. <el-button @click="ckickCell(row)" icon="el-icon-view" text type="primary">查看</el-button>
  9. </template>
  10. <template #header="">
  11. <div id="dailystoragecharts"></div>
  12. </template>
  13. <template #menu-right="{}">
  14. <el-button class="ml-3" @click="
  15. data1.Utils.exportData(
  16. '/api/v1/process/census/abnormalOperation/export'
  17. )
  18. ">
  19. <template #icon> <i-ep-download /> </template>导出
  20. </el-button>
  21. </template>
  22. </avue-crud>
  23. <el-dialog v-model="editDialog.visible" :title="editDialog.title" width="1200px"
  24. @close="editDialog.visible = false">
  25. <div class="mainContentBox">
  26. <div id="dailystoragecharts2"></div>
  27. </div>
  28. </el-dialog>
  29. </div>
  30. </template>
  31. <script setup>
  32. import { ref, getCurrentInstance } from "vue";
  33. import { useCrud } from "@/hooks/userCrud";
  34. import { useCommonStoreHook, useDictionaryStoreHook } from "@/store";
  35. import dictDataUtil from "@/common/configs/dictDataUtil";
  36. import editSkill from "@/views/base/skill/components/edit-skill.vue";
  37. import { getOperationList, getOperationInfo } from "@/api/report";
  38. import * as echarts from "echarts";
  39. // 数据字典相关
  40. const { dicts } = useDictionaryStoreHook();
  41. const editDialog = ref({ visible: false, title: "订单详情" });
  42. const charts = shallowRef(null);
  43. const charts2 = shallowRef(null);
  44. const chartsSearch = ref({});
  45. const key = ref(false);
  46. // const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  47. // useCrud({
  48. // src: "/api/v1/process/census/completeOrder",
  49. // });
  50. // ;
  51. const data1 = ref(
  52. useCrud({
  53. src: "/api/v1/process/census/completeOperation",
  54. })
  55. );
  56. const data2 = ref(
  57. useCrud({
  58. src: "/api/v1/process/census/operationList",
  59. })
  60. );
  61. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  62. data1.value.Methords;
  63. const { selectionChange, multipleDelete } = data1.value.Methords;
  64. const chartsData1 = ref({});
  65. const chartsData2 = ref({});
  66. const chartSeriesData1 = ref([]);
  67. const labelOption = {
  68. show: false,
  69. position: "insideBottom",
  70. distance: 15,
  71. align: "left",
  72. verticalAlign: "middle",
  73. rotate: 90,
  74. formatter: "{c} {name|{a}}",
  75. fontSize: 24,
  76. rich: {
  77. name: {},
  78. },
  79. };
  80. const echartOption1 = ref({
  81. title: {
  82. text: "工序完成数量",
  83. },
  84. tooltip: {
  85. trigger: "axis",
  86. axisPointer: {
  87. type: "shadow",
  88. },
  89. },
  90. legend: {
  91. // data: chartsData.value.orderCodes,
  92. data: ["工序完成数量"],
  93. },
  94. xAxis: [
  95. {
  96. type: "value",
  97. },
  98. ],
  99. yAxis: [
  100. {
  101. type: "category",
  102. axisTick: { show: false },
  103. data: [],
  104. },
  105. ],
  106. // series: chartSeriesData1.value,
  107. series: [
  108. {
  109. name: "工序完成数量",
  110. type: "bar",
  111. barGap: 0,
  112. label: labelOption,
  113. emphasis: {
  114. focus: "series",
  115. },
  116. // data: chartsData1.value.total,
  117. },
  118. ],
  119. });
  120. const echartOption2 = ref({
  121. title: {
  122. text: "生产趋势图",
  123. },
  124. tooltip: {
  125. trigger: "axis",
  126. axisPointer: {
  127. type: "shadow",
  128. },
  129. },
  130. legend: {
  131. data: [],
  132. },
  133. xAxis: [
  134. {
  135. type: "category",
  136. axisTick: { show: false },
  137. data: [],
  138. },
  139. ],
  140. yAxis: [
  141. {
  142. type: "value",
  143. },
  144. ],
  145. toolbox: {
  146. feature: {
  147. saveAsImage: {},
  148. },
  149. },
  150. series: [
  151. {
  152. name: "工序完成数量",
  153. type: "line",
  154. barGap: 0,
  155. label: labelOption,
  156. emphasis: {
  157. focus: "series",
  158. },
  159. data: [],
  160. },
  161. ],
  162. });
  163. const ckickCell = (row) => {
  164. editDialog.value.visible = true;
  165. editDialog.value.title = row.orderName;
  166. nextTick(async () => {
  167. charts2.value = echarts.init(
  168. document.getElementById("dailystoragecharts2")
  169. );
  170. chartsSearch.value.operationCode = row.operationCode;
  171. chartsSearch.value.orderCode = row.orderCode;
  172. chartsSearch.value.searchTime = data1.value.search.searchTime;
  173. echartOption2.value.title.text = row.orderName + ": 生产趋势图";
  174. await setChartsData2();
  175. echartOption2.value.xAxis[0].data = chartsData2.value.dateList;
  176. echartOption2.value.series[0].data = chartsData2.value.total;
  177. charts2.value.setOption(echartOption2.value, true);
  178. });
  179. };
  180. const setChartsData1 = async () => {
  181. const { data } = await getOperationList({
  182. ...data1.value.search,
  183. pageSize: 99999,
  184. });
  185. chartsData1.value = data;
  186. };
  187. const setChartsData2 = async () => {
  188. const { data } = await getOperationInfo({
  189. ...chartsSearch.value,
  190. });
  191. chartsData2.value = data;
  192. };
  193. // 设置表格列或者其他自定义的option
  194. data1.value.option = Object.assign(data1.value.option, {
  195. selection: false,
  196. menu: true,
  197. menuWidth: 100,
  198. addBtn: false,
  199. filterBtn: false,
  200. searchShowBtn: false,
  201. columnBtn: false,
  202. gridBtn: false,
  203. editBtn: false,
  204. viewBtn: false,
  205. delBtn: false,
  206. column: [
  207. {
  208. label: "日期范围",
  209. prop: "searchTime",
  210. search: true,
  211. hide: true,
  212. type: "date",
  213. format: "YYYY-MM-DD",
  214. valueFormat: "YYYY-MM-DD",
  215. searchRange: true,
  216. startPlaceholder: "开始日期",
  217. endPlaceholder: "结束日期",
  218. },
  219. {
  220. label: "订单编码",
  221. prop: "orderCode",
  222. overHidden: true,
  223. search: true,
  224. editDisabled: true,
  225. hide: true,
  226. },
  227. {
  228. label: "订单名称",
  229. prop: "orderName",
  230. overHidden: true,
  231. search: true,
  232. editDisabled: true,
  233. hide: true,
  234. },
  235. {
  236. label: "项目编码",
  237. prop: "projectCode",
  238. overHidden: true,
  239. search: true,
  240. editDisabled: true,
  241. hide: true,
  242. },
  243. {
  244. label: "产品规格",
  245. prop: "materialModel",
  246. width: 140,
  247. overHidden: true,
  248. search: true,
  249. editDisabled: true,
  250. hide: true,
  251. },
  252. {
  253. label: "订单名称",
  254. prop: "orderName",
  255. search: false,
  256. },
  257. {
  258. label: "订单编码",
  259. prop: "orderCode",
  260. search: false,
  261. },
  262. {
  263. label: "项目编码",
  264. prop: "projectCode",
  265. search: false,
  266. },
  267. {
  268. label: "物料编码",
  269. prop: "materialCode",
  270. search: false,
  271. },
  272. {
  273. label: "物料名称",
  274. prop: "materialName",
  275. search: false,
  276. },
  277. {
  278. label: "物料规格",
  279. prop: "materialModel",
  280. search: false,
  281. },
  282. {
  283. label: "工序编码",
  284. prop: "operationCode",
  285. search: false,
  286. },
  287. {
  288. label: "工序名称",
  289. prop: "operationName",
  290. search: false,
  291. },
  292. {
  293. label: "完工日期",
  294. prop: "realEndWhen",
  295. search: false,
  296. },
  297. {
  298. label: "总完工数量",
  299. prop: "total",
  300. search: false,
  301. },
  302. ],
  303. });
  304. const getCurrentMonthStartAndEndDates = () => {
  305. // 获取当前日期
  306. let now = new Date();
  307. // 获取当前月份的第一天
  308. let startDate = new Date(now.getFullYear(), now.getMonth(), 1);
  309. // 获取当前月份的最后一天
  310. let endDate = new Date(now.getFullYear(), now.getMonth() + 1, 0);
  311. // 格式化日期为'YYYY-MM-DD'格式
  312. function formatDate(date) {
  313. let year = date.getFullYear();
  314. let month = String(date.getMonth() + 1).padStart(2, "0");
  315. let day = String(date.getDate()).padStart(2, "0");
  316. return `${year}-${month}-${day}`;
  317. }
  318. // 返回包含开始和结束日期的数组
  319. return [formatDate(startDate), formatDate(endDate)];
  320. };
  321. //设置搜索条件中的时间范围为默认此月
  322. const setTime = () => {
  323. data1.value.search.searchTime = getCurrentMonthStartAndEndDates();
  324. };
  325. onMounted(async () => {
  326. setTime();
  327. charts.value = echarts.init(document.getElementById("dailystoragecharts"));
  328. dataList();
  329. await setChartsData1();
  330. echartOption1.value.yAxis[0].data = chartsData1.value.operationList;
  331. echartOption1.value.series[0].data = chartsData1.value.total;
  332. charts.value.setOption(echartOption1.value, true);
  333. });
  334. </script>
  335. <style lang="scss" scoped>
  336. :deep(.avue-crud__left) {
  337. width: 100%;
  338. }
  339. #dailystoragecharts {
  340. width: 100%;
  341. height: 400px;
  342. border: 1px solid #ccc;
  343. }
  344. #dailystoragecharts2 {
  345. width: 100%;
  346. height: 400px;
  347. border: 1px solid #ccc;
  348. }
  349. </style>