index.vue 8.8 KB

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