index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud ref="crudRef" v-model:search="search" v-model="form" :data="data" :option="option" v-model:page="page"
  4. @row-save="createRow" @row-update="updateRow" @row-del="deleteRow" @search-change="searchChange"
  5. @search-reset="resetChange" @size-change="dataList" @current-change="dataList"
  6. @selection-change="selectionChange">
  7. <template #menu="{ size, row, index }">
  8. <el-button icon="el-icon-edit" text v-if="row.state === '-1' || row.state === '0'"
  9. @click="handleEdit(row, index)" type="primary" :size="size">编辑</el-button>
  10. </template>
  11. <template #menu-left>
  12. <div id="charts"></div>
  13. </template>
  14. </avue-crud>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ref } from "vue";
  19. import { useCrud } from "@/hooks/userCrud";
  20. import dictDataUtil from "@/common/configs/dictDataUtil";
  21. import { queryStationByLineId } from "@/api/station";
  22. import { useDictionaryStoreHook } from "@/store";
  23. import { getStatistics } from "@/api/order/index";
  24. import * as echarts from "echarts";
  25. // 数据字典相关
  26. const { dicts } = useDictionaryStoreHook();
  27. // 传入一个url,后面不带/
  28. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  29. useCrud({
  30. src: "/api/v1/plan/task",
  31. });
  32. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  33. Methords; //增删改查
  34. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  35. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  36. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  37. const stationList = ref([]);
  38. const charts = shallowRef(null);
  39. const handleEdit = (row, index) => {
  40. queryStationByLineId(row.productLineId).then((data) => {
  41. stationList.value = data.data;
  42. });
  43. crudRef.value && crudRef.value.rowEdit(row, index);
  44. };
  45. onMounted(() => {
  46. charts.value = echarts.init(document.getElementById("charts"));
  47. dataList();
  48. getStatistics(search.value).then((res) => {
  49. const { data } = res;
  50. const { value, key } = data;
  51. charts.value.setOption({
  52. title: {
  53. text: "任务状态统计图",
  54. left: "center",
  55. },
  56. tooltip: {
  57. trigger: "item",
  58. },
  59. xAxis: {
  60. data: key,
  61. },
  62. yAxis: {},
  63. series: [
  64. {
  65. type: "bar",
  66. data: value,
  67. itemStyle: {
  68. barBorderRadius: 5,
  69. borderWidth: 1,
  70. borderType: "solid",
  71. borderColor: "#73c0de",
  72. shadowColor: "#5470c6",
  73. shadowBlur: 3,
  74. },
  75. },
  76. ],
  77. });
  78. });
  79. });
  80. // 设置表格列或者其他自定义的option
  81. option.value = Object.assign(option.value, {
  82. selection: true,
  83. menu: true,
  84. menuWidth: 100,
  85. addBtn: false,
  86. filterBtn: false,
  87. searchShowBtn: false,
  88. columnBtn: false,
  89. gridBtn: false,
  90. editBtn: false,
  91. viewBtn: false,
  92. delBtn: false,
  93. column: [
  94. {
  95. label: "流转卡号",
  96. prop: "seqNo",
  97. editDisabled: true,
  98. search: true,
  99. },
  100. {
  101. label: "工位名称",
  102. prop: "stationName",
  103. search: true,
  104. display: false,
  105. },
  106. {
  107. label: "工位名称",
  108. hide: true,
  109. editDisabled: false,
  110. type: "select",
  111. dicData: stationList,
  112. prop: "stationId",
  113. props: { label: "name", value: "id" },
  114. rules: [
  115. {
  116. required: true,
  117. message: "请选择工位名称",
  118. trigger: "blur",
  119. },
  120. ],
  121. },
  122. {
  123. label: "工单编码",
  124. prop: "workOrderCode",
  125. search: true,
  126. width: 125,
  127. editDisabled: true,
  128. },
  129. {
  130. label: "产线名称",
  131. prop: "productLineName",
  132. editDisabled: true,
  133. },
  134. {
  135. label: "工艺路线",
  136. prop: "routeName",
  137. editDisabled: true,
  138. },
  139. {
  140. label: "物料编号",
  141. prop: "materialCode",
  142. search: true,
  143. editDisabled: true,
  144. },
  145. {
  146. label: "工序编码",
  147. prop: "operationCode",
  148. editDisabled: true,
  149. search: true,
  150. },
  151. {
  152. label: "工序名称",
  153. prop: "operationName",
  154. editDisabled: true,
  155. },
  156. {
  157. label: "排序",
  158. prop: "operationSort",
  159. formatter: (val) => {
  160. return val.operationSort + 1;
  161. },
  162. editDisabled: true,
  163. width: 60,
  164. },
  165. {
  166. label: "状态",
  167. prop: "state",
  168. type: "select",
  169. search: true,
  170. width: 80,
  171. editDisabled: true,
  172. dicUrl:
  173. dictDataUtil.request_url + dictDataUtil.TYPE_CODE.station_task_state,
  174. props: {
  175. label: "dictLabel",
  176. value: "dictValue",
  177. },
  178. },
  179. {
  180. label: "开始时间",
  181. prop: "planStartWhen",
  182. type: "datetime",
  183. valueFormat: "YYYY-MM-DD HH:mm:ss",
  184. },
  185. {
  186. label: "结束时间",
  187. prop: "planStartEnd",
  188. type: "datetime",
  189. valueFormat: "YYYY-MM-DD HH:mm:ss",
  190. },
  191. ],
  192. });
  193. </script>
  194. <style lang="scss" scoped>
  195. :deep(.avue-crud__left) {
  196. width: 100%;
  197. }
  198. #charts {
  199. width: 100%;
  200. height: 300px;
  201. border: 1px solid #ccc;
  202. }
  203. </style>