index.vue 7.3 KB

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