screwdriver.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <div class="containerBox">
  3. <el-collapse>
  4. <el-collapse-item
  5. v-for="(item, index) in materialsData"
  6. :key="index + item"
  7. :name="index"
  8. >
  9. <template #title>
  10. {{
  11. dictS.getLableByValue("device_type", item.deviceType)
  12. }}&nbsp;&nbsp;&nbsp;<span
  13. :class="item.state ? 'round green' : 'round'"
  14. ></span
  15. >&nbsp; &nbsp;
  16. <span
  17. @click.stop="
  18. addItem(item.deviceNo, item.deviceName, item.deviceType, index)
  19. "
  20. class="opear"
  21. style="font-size: 18px; color: rgb(10, 89, 247); font-weight: 600"
  22. >新增数据</span
  23. >
  24. </template>
  25. <el-table :data="tableData[index]" border :key="tableKey">
  26. <!-- <el-table-column prop="deviceNo" label="设备编号">
  27. <template #default="scope" v-if="!item.updateStatus">
  28. {{ scope.row.deviceNo }}
  29. </template>
  30. <template #default v-else>
  31. <el-input v-model="tableData[index].deviceNo" />
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="deviceName" label="设备名称">
  35. <template #default="scope" v-if="!item.updateStatus">
  36. {{ scope.row.deviceName }}
  37. </template>
  38. <template #default v-else>
  39. <el-input v-model="tableData[index].deviceName" />
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="created" label="采集时间">
  43. <template #default="scope" v-if="!item.updateStatus">
  44. {{ scope.row.created }}
  45. </template>
  46. <template #default v-else>
  47. <el-input v-model="tableData[index].created" />
  48. </template>
  49. </el-table-column> -->
  50. <el-table-column
  51. v-for="str in configeObj(materialsData[index].deviceType)"
  52. :key="str"
  53. :prop="str"
  54. :label="showLable(str)"
  55. width="230px"
  56. >
  57. <template #default="{ row }">
  58. <div v-if="!row.updateStatus">
  59. {{ row.data[str] }}
  60. </div>
  61. <div v-else>
  62. <el-input v-model="tableData[index][row.index].data[str]" />
  63. </div>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作" min-width="150px" fixed="right">
  67. <template #default="scope">
  68. <span
  69. class="opear"
  70. v-if="scope.row.updateStatus || scope.row.addStatus"
  71. @click="toSuccess(index, scope.$index)"
  72. >完成</span
  73. >
  74. <span class="opear" v-else @click="toDelete(index, scope.$index)"
  75. >删除</span
  76. >
  77. <span
  78. class="opear"
  79. v-if="scope.row.updateStatus || scope.row.addStatus"
  80. @click="toCancel(index, scope.$index)"
  81. >取消</span
  82. ><span class="opear" v-else @click="toEdit(index, scope.$index)"
  83. >编辑</span
  84. >
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <Pagination
  89. v-model:limit="pageS[index].pageSize"
  90. v-model:page="pageS[index].pageNo"
  91. :total="pageS[index].total"
  92. @pagination="paginationChange(index)"
  93. position="right"
  94. />
  95. </el-collapse-item>
  96. </el-collapse>
  97. </div>
  98. </template>
  99. <script setup>
  100. import {
  101. getScrewdriverData,
  102. getAcquisitionData,
  103. addAcquisitionData,
  104. updateAcquisitionData,
  105. delAcquisitionData,
  106. } from "@/api/prosteps/screwdriver";
  107. import { useProcessStore } from "@/store";
  108. import { useDictionaryStore } from "@/store";
  109. const dictS = useDictionaryStore();
  110. const store = useProcessStore();
  111. const tableData = ref([]);
  112. const materialsData = ref([]);
  113. const showLable = (key) => {
  114. switch (key) {
  115. case "CH5Val":
  116. return "CH5";
  117. case "CH6Val":
  118. return "CH6";
  119. case "DataTimes":
  120. return "采集时间";
  121. case "DDLSD1":
  122. return "拧紧的模式";
  123. case "DDLSD2":
  124. return "拧紧旋转方向";
  125. case "DDLSD3":
  126. return "目标扭力";
  127. case "DDLSD4":
  128. return "扭力保持时间";
  129. case "DDLSD5":
  130. return "浮高界定圈数";
  131. case "DDLSD6":
  132. return "滑牙界定圈数";
  133. case "DDLSD7":
  134. return "触发速度切换的扭力比值";
  135. case "DDLSD8":
  136. return "扭力补偿值";
  137. case "DDLSD9":
  138. return "开启浮高滑牙检测";
  139. case "DDLSD10":
  140. return "触发速度切换的扭力";
  141. case "DDLSD11":
  142. return "触发速度切换的速度比值";
  143. case "DDLSD12":
  144. return "扭力偏差上限";
  145. case "DDLSD13":
  146. return "扭力偏差下限";
  147. case "DDLSD14":
  148. return "扭力免检圈数";
  149. case "DDLSD15":
  150. return "拧松有效触发的扭力阀值";
  151. case "DDLSD16":
  152. return "拧松有效触发的保持时间";
  153. case "DDLSD17":
  154. return "自由旋转方向";
  155. case "DDLSD18":
  156. return "STEP-00拧紧圈数";
  157. case "DDLSD19":
  158. return "STEP-00拧紧速度";
  159. case "DDLSD20":
  160. return "STEP-01拧紧圈数";
  161. case "DDLSD21":
  162. return "STEP-01拧紧速度";
  163. case "DDLSD22":
  164. return "STEP-02拧紧圈数";
  165. case "DDLSD23":
  166. return "STEP-02拧紧速度";
  167. case "DDLSD24":
  168. return "STEP-03拧紧圈数";
  169. case "DDLSD25":
  170. return "STEP-03拧紧速度";
  171. case "DDLSD26":
  172. return "STEP-04拧紧圈数";
  173. case "DDLSD27":
  174. return "STEP-04拧紧速度";
  175. case "DDLSD28":
  176. return "STEP-00拧松圈数";
  177. case "DDLSD29":
  178. return "STEP-00拧松速度";
  179. case "DDLSD30":
  180. return "STEP-01拧松圈数";
  181. case "DDLSD31":
  182. return "STEP-01拧松速度";
  183. case "DDLSD32":
  184. return "STEP-02拧松圈数";
  185. case "DDLSD33":
  186. return "STEP-02拧松速度";
  187. case "DDLSD34":
  188. return "STEP-00自由圈数";
  189. case "DDLSD35":
  190. return "STEP-00自由速度";
  191. default:
  192. return key;
  193. }
  194. };
  195. const toEdit = (index, rowIndex) => {
  196. tableData.value[index][rowIndex].updateStatus = true;
  197. };
  198. const toDelete = async (index, rowIndex) => {
  199. console.log(index, rowIndex);
  200. const no = tableData.value[index][rowIndex].deviceNo;
  201. const { code } = await delAcquisitionData({
  202. id: tableData.value[index][rowIndex].id,
  203. });
  204. if (code == "200") {
  205. ElMessage.success("操作成功!");
  206. setAcquisitionDatas(no, index);
  207. }
  208. };
  209. const toSuccess = (index, rowIndex) => {
  210. if (tableData.value[index][rowIndex].addStatus == true) {
  211. addInfo(index, rowIndex);
  212. } else {
  213. editInfo(index, rowIndex);
  214. }
  215. };
  216. const addInfo = async (index, rowIndex) => {
  217. const { code } = await addAcquisitionData({
  218. ...tableData.value[index][rowIndex],
  219. data: JSON.stringify(tableData.value[index][rowIndex].data),
  220. });
  221. if (code == "200") {
  222. ElMessage.success("操作成功!");
  223. tableData.value[index][rowIndex].addStatus = false;
  224. tableData.value[index][rowIndex].updateStatus = false;
  225. }
  226. };
  227. const editInfo = async (index, rowIndex) => {
  228. const { code } = await updateAcquisitionData({
  229. ...tableData.value[index][rowIndex],
  230. data: JSON.stringify(tableData.value[index][rowIndex].data),
  231. });
  232. if (code == "200") {
  233. ElMessage.success("操作成功!");
  234. tableData.value[index][rowIndex].updateStatus = false;
  235. }
  236. };
  237. const toCancel = (index, rowIndex) => {
  238. if (tableData.value[index][rowIndex].addStatus == true) {
  239. tableData.value[index].splice(rowIndex, 1);
  240. } else {
  241. tableData.value[index][rowIndex].updateStatus = false;
  242. tableData.value[index][rowIndex].data = JSON.parse(
  243. tableData.value[index][rowIndex].resdata
  244. );
  245. }
  246. };
  247. const configeObj = (type) => {
  248. switch (type) {
  249. //温湿度
  250. case "WXDJC":
  251. return ["CH5Val", "CH6Val", "DataTimes"];
  252. //电动螺丝刀
  253. case "DDLSD":
  254. return [
  255. "DDLSD1",
  256. "DDLSD2",
  257. "DDLSD3",
  258. "DDLSD4",
  259. "DDLSD5",
  260. "DDLSD6",
  261. "DDLSD7",
  262. "DDLSD8",
  263. "DDLSD9",
  264. "DDLSD10",
  265. "DDLSD11",
  266. "DDLSD12",
  267. "DDLSD13",
  268. "DDLSD14",
  269. "DDLSD15",
  270. "DDLSD16",
  271. "DDLSD17",
  272. "DDLSD18",
  273. "DDLSD19",
  274. "DDLSD20",
  275. "DDLSD21",
  276. "DDLSD22",
  277. "DDLSD23",
  278. "DDLSD24",
  279. "DDLSD25",
  280. "DDLSD26",
  281. "DDLSD27",
  282. "DDLSD28",
  283. "DDLSD29",
  284. "DDLSD30",
  285. "DDLSD31",
  286. "DDLSD32",
  287. "DDLSD33",
  288. "DDLSD34",
  289. "DDLSD35",
  290. ];
  291. default:
  292. return ["a", "b", "c"];
  293. }
  294. };
  295. const addItem = (no, name, type, index) => {
  296. let data = {};
  297. switch (type) {
  298. case "WXDJC":
  299. data = { CH5Val: "", CH6Val: "", DataTimes: "" };
  300. break;
  301. case "DDLSD":
  302. data = {
  303. DDLSD1: "",
  304. DDLSD2: "",
  305. DDLSD3: "",
  306. DDLSD4: "",
  307. DDLSD5: "",
  308. DDLSD6: "",
  309. DDLSD7: "",
  310. DDLSD8: "",
  311. DDLSD9: "",
  312. DDLSD10: "",
  313. DDLSD11: "",
  314. DDLSD12: "",
  315. DDLSD13: "",
  316. DDLSD14: "",
  317. DDLSD15: "",
  318. DDLSD16: "",
  319. DDLSD17: "",
  320. DDLSD18: "",
  321. DDLSD19: "",
  322. DDLSD20: "",
  323. DDLSD21: "",
  324. DDLSD22: "",
  325. DDLSD23: "",
  326. DDLSD24: "",
  327. DDLSD25: "",
  328. DDLSD26: "",
  329. DDLSD27: "",
  330. DDLSD28: "",
  331. DDLSD29: "",
  332. DDLSD30: "",
  333. DDLSD31: "",
  334. DDLSD32: "",
  335. DDLSD33: "",
  336. DDLSD34: "",
  337. DDLSD35: "",
  338. };
  339. break;
  340. }
  341. tableData.value[index].push({
  342. deviceNo: no,
  343. deviceName: name,
  344. deviceType: type,
  345. data: data,
  346. operationId: store.odersData.operationId,
  347. operationName: store.processInfo.operationName,
  348. processId: store.scanInfo.id,
  349. seqNo: store.scanInfo.seqNo,
  350. workOrderCode: store.odersData.workOrderCode,
  351. index: tableData.value[index].length,
  352. addStatus: true,
  353. updateStatus: true,
  354. });
  355. };
  356. const tableKey = ref(false);
  357. const getData = async () => {
  358. const res = await getScrewdriverData();
  359. materialsData.value = res.data;
  360. materialsData.value.forEach((item, index) => {
  361. pageS.value.push({ ...page });
  362. getAcquisitionDatas(item.deviceNo, index);
  363. });
  364. change();
  365. };
  366. const paginationChange = (index1) => {
  367. materialsData.value.forEach((item, index) => {
  368. if (index == index1) {
  369. setAcquisitionDatas(item.deviceNo, index);
  370. }
  371. });
  372. };
  373. const getAcquisitionDatas = async (No, index) => {
  374. const res = await getAcquisitionData({
  375. deviceNo: No,
  376. operationId: store.odersData.operationId,
  377. pageNo: pageS.value[index].pageNo,
  378. pageSize: pageS.value[index].pageSize,
  379. processId: store.scanInfo.id,
  380. });
  381. pageS.value[index].total = res.data.totalCount;
  382. res.data.records.forEach((item, index) => {
  383. item.resdata = item.data;
  384. item.data = JSON.parse(item.data);
  385. item.updateStatus = false;
  386. item.index = index;
  387. });
  388. tableData.value.push(res.data.records);
  389. };
  390. const setAcquisitionDatas = async (No, index) => {
  391. const res = await getAcquisitionData({
  392. deviceNo: No,
  393. operationId: store.odersData.operationId,
  394. pageNo: pageS.value[index].pageNo,
  395. pageSize: pageS.value[index].pageSize,
  396. processId: store.scanInfo.id,
  397. });
  398. pageS.value[index].total = res.data.totalCount;
  399. res.data.records.forEach((item, index) => {
  400. item.resdata = item.data;
  401. item.data = JSON.parse(item.data);
  402. item.updateStatus = false;
  403. item.index = index;
  404. });
  405. console.log(index, res.data.records);
  406. tableData.value[index] = res.data.records;
  407. console.log(tableData.value);
  408. change();
  409. };
  410. const pageS = ref([]);
  411. const page = {
  412. pageSize: 10,
  413. pageNo: 1,
  414. total: 0,
  415. };
  416. onMounted(async () => {
  417. await getData();
  418. });
  419. onActivated(() => {
  420. change();
  421. });
  422. const change = () => {
  423. setTimeout(() => {
  424. tableKey.value = !tableKey.value;
  425. }, 0);
  426. };
  427. </script>
  428. <style lang="scss" scoped>
  429. .containerBox {
  430. background-color: white;
  431. padding: 20px;
  432. }
  433. :deep(.el-collapse-item__header) {
  434. background-color: rgb(241, 243, 245) !important;
  435. padding: 0 20px;
  436. height: 80px;
  437. }
  438. :deep(.el-badge) {
  439. font-size: $f24;
  440. }
  441. :deep(.el-collapse-item__header) {
  442. font-size: $f24;
  443. }
  444. :deep(.el-pagination) {
  445. span {
  446. font-weight: 600 !important;
  447. }
  448. }
  449. :deep(.el-collapse-item__wrap) {
  450. padding: 20px;
  451. border: 1px solid rgb(241, 243, 245);
  452. }
  453. .opear {
  454. font-size: 16px;
  455. margin-right: 5px;
  456. cursor: pointer;
  457. }
  458. .round {
  459. width: 20px;
  460. height: 20px;
  461. border-radius: 10px;
  462. background-color: red;
  463. }
  464. .green {
  465. background-color: green;
  466. }
  467. </style>