123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- <template>
- <div class="containerBox">
- <el-collapse>
- <el-collapse-item
- v-for="(item, index) in materialsData"
- :key="index + item"
- :name="index"
- :disabled="item.deviceType == 'FJDJC'"
- style="position: relative"
- >
- <template #title>
- <span class="diviceName">
- {{ dictS.getLableByValue("device_type", item.deviceType) }}</span
- >
- <span
- :class="item.state ? 'round green' : 'round'"
- ></span
- >
- <span
- @click.stop="
- addItem(item.deviceNo, item.deviceName, item.deviceType, index)
- "
- v-if="item.deviceType != 'FJDJC'"
- class="opear"
- style="font-size: 18px; color: rgb(10, 89, 247); font-weight: 600"
- >新增数据</span
- >
- <!-- DDLSD -->
- <el-select
- v-model="taskValue"
- v-if="item.deviceType == 'DDLSD'"
- placeholder="请选择任务"
- size="large"
- @change="changeTask"
- style="position: absolute; right: 460px; z-index: 2; width: 140px"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <el-button
- class="ces"
- type="primary"
- style="position: absolute; right: 340px; z-index: 2"
- v-if="item.deviceType == 'DDLSD'"
- @click.stop="
- startTest1(item.deviceName, item.deviceNo, item.deviceType)
- "
- :disabled="
- (item.deviceType == 'DDLSD' && !taskValue) ||
- btnDisabled ||
- setDiabledStatus
- "
- >设置参数</el-button
- >
- <el-select
- v-model="taskId"
- v-if="item.deviceType == 'DDLSD'"
- placeholder="选择任务号"
- size="large"
- style="position: absolute; right: 180px; z-index: 2; width: 140px"
- >
- <el-option
- v-for="item in options2"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <!-- DDLSD -->
- <!-- WKDLT -->
- <el-input-number
- @click.stop
- style="
- position: absolute;
- right: 300px;
- z-index: 2;
- margin-bottom: 1px;
- "
- v-model="tipTemperature"
- :min="50"
- :max="450"
- v-if="item.deviceType == 'WKDLT'"
- />
- <span
- v-if="item.deviceType == 'WKDLT'"
- style="
- position: absolute;
- right: 345px;
- z-index: 2;
- margin-bottom: 1px;
- font-size: 16px;
- color: black !important;
- "
- >℃</span
- >
- <el-button
- class="ces"
- type="primary"
- style="position: absolute; right: 180px; z-index: 2"
- v-if="item.deviceType == 'WKDLT'"
- @click.stop="setTipTemperature"
- :disabled="tipTemperatureDisabled"
- >设置温度</el-button
- >
- <!-- WKDLT -->
- <el-button
- class="ces"
- type="primary"
- style="position: absolute; right: 60px; z-index: 2"
- v-if="item.deviceType != 'FJDJC'"
- @click.stop="
- startTest(item.deviceName, item.deviceNo, item.deviceType)
- "
- :disabled="
- (item.deviceType == 'DDLSD' && !taskValue) || btnDisabled
- "
- >开始检测</el-button
- >
- </template>
- <el-table
- :data="tableData[index]"
- v-if="item.deviceType != 'FJDJC'"
- border
- >
- <el-table-column
- v-for="str in configeObj(materialsData[index].deviceType)"
- :key="str"
- :prop="str"
- :label="showLable(str)"
- >
- <template #default="{ row }">
- <div v-if="!row.updateStatus">
- {{ row.data[str] }}
- </div>
- <div v-else>
- <el-input v-model="tableData[index][row.index].data[str]" />
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="created" label="采集时间" width="230px">
- <template #default="{ row }">
- <div v-if="!row.updateStatus">
- {{ row.created }}
- </div>
- <div v-else>
- <el-input v-model="tableData[index][row.index].created" />
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" min-width="150px" fixed="right">
- <template #default="scope">
- <span
- class="opear"
- v-if="scope.row.updateStatus || scope.row.addStatus"
- @click="toSuccess(index, scope.$index)"
- >完成</span
- >
- <span class="opear" v-else @click="toDelete(index, scope.$index)"
- >删除</span
- >
- <span
- class="opear"
- v-if="scope.row.updateStatus || scope.row.addStatus"
- @click="toCancel(index, scope.$index)"
- >取消</span
- ><span class="opear" v-else @click="toEdit(index, scope.$index)"
- >编辑</span
- >
- </template>
- </el-table-column>
- </el-table>
- <Pagination
- v-if="item.deviceType != 'FJDJC'"
- v-model:limit="pageS[index].pageSize"
- v-model:page="pageS[index].pageNo"
- :total="pageS[index].total"
- @pagination="paginationChange(index)"
- position="right"
- />
- </el-collapse-item>
- </el-collapse>
- </div>
- </template>
- <script setup>
- import {
- getScrewdriverData,
- getAcquisitionData,
- addAcquisitionData,
- updateAcquisitionData,
- delAcquisitionData,
- getTaskList,
- startData,
- setUpData,
- setUpData1,
- } from "@/api/prosteps/screwdriver";
- import { useProcessStore } from "@/store";
- import { useDictionaryStore } from "@/store";
- import { emitter, EventsNames } from "@/utils/common";
- defineOptions({
- name: "Screwdriver",
- });
- const dictS = useDictionaryStore();
- const store = useProcessStore();
- const tipTemperature = ref(50);
- const tipTemperatureDisabled = ref(false);
- const setTipTemperature = async () => {
- try {
- tipTemperatureDisabled.value = true;
- const { code } = await setUpData1({ tipTemperature: tipTemperature.value });
- if (code == "200") {
- ElMessage.success("设置成功!");
- }
- } catch (e) {
- } finally {
- setTimeout(() => {
- tipTemperatureDisabled.value = false;
- }, 5000);
- }
- };
- const changeTask = () => {
- setDiabledStatus.value = false;
- };
- const setDiabledStatus = ref(false);
- const tableData = ref([]);
- const materialsData = ref([]);
- const router = useRouter();
- const taskValue = ref("");
- const taskId = ref("1");
- const btnDisabled = ref(false);
- const toStartData = async (data) => {
- try {
- btnDisabled.value = true;
- const { code } = await startData(data);
- if (code == "200") {
- ElMessage.success("开始检测....");
- }
- } catch (e) {
- } finally {
- setTimeout(() => {
- btnDisabled.value = false;
- }, 3000);
- }
- };
- const toStartData1 = async (data) => {
- try {
- btnDisabled.value = true;
- const { code } = await setUpData(data);
- if (code == "200") {
- ElMessage.success("设置成功!");
- setDiabledStatus.value = true;
- }
- } catch (e) {
- } finally {
- setTimeout(() => {
- btnDisabled.value = false;
- }, 3000);
- }
- };
- const getTask = async () => {
- let params = {
- operationCode: store.processInfo.operationCode,
- materialNo: store.scanInfo.materialCode,
- };
- const { data } = await getTaskList(params);
- options.value = [];
- data.forEach((item) => {
- options.value.push({
- value: item.id,
- label: item.taskName,
- });
- });
- };
- const options = ref([]);
- const options2 = ref([
- { value: "1", label: "任务0" },
- { value: "2", label: "任务1" },
- { value: "3", label: "任务2" },
- { value: "4", label: "任务3" },
- { value: "5", label: "任务4" },
- { value: "6", label: "任务5" },
- { value: "7", label: "任务6" },
- { value: "8", label: "任务7" },
- ]);
- const startTest = (a, b, c) => {
- let obj = {
- deviceName: a,
- deviceNo: b,
- deviceType: c,
- operationId: store.scanInfo.operationId,
- operationName: store.processInfo.operationName,
- processId: store.scanInfo.id,
- seqNo: store.useSeqNo,
- workOrderCode: store.odersData.workOrderCode,
- taskId: taskValue.value,
- smallTaskId: taskId.value,
- };
- toStartData(obj);
- };
- const startTest1 = (a, b, c) => {
- let obj = {
- deviceName: a,
- deviceNo: b,
- deviceType: c,
- operationId: store.scanInfo.operationId,
- operationName: store.processInfo.operationName,
- processId: store.scanInfo.id,
- seqNo: store.useSeqNo,
- workOrderCode: store.odersData.workOrderCode,
- taskId: taskValue.value,
- smallTaskId: taskId.value,
- };
- toStartData1(obj);
- };
- const showLable = (key) => {
- switch (key) {
- case "tipTemperature":
- return "温度";
- case "CH5Val":
- return "温度";
- case "CH6Val":
- return "湿度";
- case "DataTimes":
- return "采集时间";
- case "torquetarget":
- return "当前任务目标扭力";
- case "tightenTorqueMax":
- return "拧紧过程中最大扭力值";
- case "taskNo":
- return "当前任务号";
- case "taskName":
- return "任务名";
- case "warning":
- return "警报";
- case "tightenResult":
- return "最终拧紧结果";
- case "totalCycles":
- return "总圈数";
- case "length":
- return "长度";
- case "height":
- return "高度";
- case "DDLSD1":
- return "拧紧的模式";
- case "DDLSD2":
- return "拧紧旋转方向";
- case "DDLSD3":
- return "目标扭力";
- case "DDLSD4":
- return "扭力保持时间";
- case "DDLSD5":
- return "浮高界定圈数";
- case "DDLSD6":
- return "滑牙界定圈数";
- case "DDLSD7":
- return "触发速度切换的扭力比值";
- case "DDLSD8":
- return "扭力补偿值";
- case "DDLSD9":
- return "开启浮高滑牙检测";
- case "DDLSD10":
- return "触发速度切换的扭力";
- case "DDLSD11":
- return "触发速度切换的速度比值";
- case "DDLSD12":
- return "扭力偏差上限";
- case "DDLSD13":
- return "扭力偏差下限";
- case "DDLSD14":
- return "扭力免检圈数";
- case "DDLSD15":
- return "拧松有效触发的扭力阀值";
- case "DDLSD16":
- return "拧松有效触发的保持时间";
- case "DDLSD17":
- return "自由旋转方向";
- case "DDLSD18":
- return "STEP-00拧紧圈数";
- case "DDLSD19":
- return "STEP-00拧紧速度";
- case "DDLSD20":
- return "STEP-01拧紧圈数";
- case "DDLSD21":
- return "STEP-01拧紧速度";
- case "DDLSD22":
- return "STEP-02拧紧圈数";
- case "DDLSD23":
- return "STEP-02拧紧速度";
- case "DDLSD24":
- return "STEP-03拧紧圈数";
- case "DDLSD25":
- return "STEP-03拧紧速度";
- case "DDLSD26":
- return "STEP-04拧紧圈数";
- case "DDLSD27":
- return "STEP-04拧紧速度";
- case "DDLSD28":
- return "STEP-00拧松圈数";
- case "DDLSD29":
- return "STEP-00拧松速度";
- case "DDLSD30":
- return "STEP-01拧松圈数";
- case "DDLSD31":
- return "STEP-01拧松速度";
- case "DDLSD32":
- return "STEP-02拧松圈数";
- case "DDLSD33":
- return "STEP-02拧松速度";
- case "DDLSD34":
- return "STEP-00自由圈数";
- case "DDLSD35":
- return "STEP-00自由速度";
- default:
- return key;
- }
- };
- const toEdit = (index, rowIndex) => {
- tableData.value[index][rowIndex].updateStatus = true;
- };
- const toDelete = async (index, rowIndex) => {
- const no = tableData.value[index][rowIndex].deviceNo;
- const { code } = await delAcquisitionData({
- id: tableData.value[index][rowIndex].id,
- });
- if (code == "200") {
- ElMessage.success("操作成功!");
- setAcquisitionDatas(no, index);
- }
- };
- const toSuccess = (index, rowIndex) => {
- if (tableData.value[index][rowIndex].addStatus == true) {
- addInfo(index, rowIndex);
- } else {
- editInfo(index, rowIndex);
- }
- };
- const addInfo = async (index, rowIndex) => {
- const { code } = await addAcquisitionData({
- ...tableData.value[index][rowIndex],
- data: JSON.stringify(tableData.value[index][rowIndex].data),
- });
- if (code == "200") {
- ElMessage.success("操作成功!");
- tableData.value[index][rowIndex].addStatus = false;
- tableData.value[index][rowIndex].updateStatus = false;
- }
- };
- const editInfo = async (index, rowIndex) => {
- const { code } = await updateAcquisitionData({
- ...tableData.value[index][rowIndex],
- data: JSON.stringify(tableData.value[index][rowIndex].data),
- });
- if (code == "200") {
- ElMessage.success("操作成功!");
- tableData.value[index][rowIndex].updateStatus = false;
- }
- };
- const toCancel = (index, rowIndex) => {
- if (tableData.value[index][rowIndex].addStatus == true) {
- tableData.value[index].splice(rowIndex, 1);
- } else {
- tableData.value[index][rowIndex].updateStatus = false;
- tableData.value[index][rowIndex].data = JSON.parse(
- tableData.value[index][rowIndex].resdata
- );
- }
- };
- //根据类型返横列字段
- const configeObj = (type) => {
- switch (type) {
- //温湿度
- case "WXDJC":
- return ["CH5Val", "CH6Val"];
- case "YBKC":
- return ["length"];
- case "GDC":
- return ["height"];
- case "WKDLT":
- return ["tipTemperature"];
- //电动螺丝刀
- case "DDLSD":
- return [
- "taskName",
- "taskNo",
- "tightenResult",
- "totalCycles",
- "torquetarget",
- "tightenTorqueMax",
- "warning",
- ];
- default:
- return ["数据1", "数据2", "数据3"];
- }
- };
- const addItem = (no, name, type, index) => {
- let data = {};
- switch (type) {
- case "WXDJC":
- data = { CH5Val: "", CH6Val: "", DataTimes: "" };
- break;
- case "YBCK":
- data = { CH5Val: "", CH6Val: "", DataTimes: "" };
- break;
- case "WKDLT":
- data = { temperature: "" };
- break;
- case "GDC":
- data = { CH5Val: "", CH6Val: "", DataTimes: "" };
- break;
- case "DDLSD":
- data = {
- DDLSD1: "",
- DDLSD2: "",
- DDLSD3: "",
- DDLSD4: "",
- DDLSD5: "",
- DDLSD6: "",
- DDLSD7: "",
- DDLSD8: "",
- DDLSD9: "",
- DDLSD10: "",
- DDLSD11: "",
- DDLSD12: "",
- DDLSD13: "",
- DDLSD14: "",
- DDLSD15: "",
- DDLSD16: "",
- DDLSD17: "",
- DDLSD18: "",
- DDLSD19: "",
- DDLSD20: "",
- DDLSD21: "",
- DDLSD22: "",
- DDLSD23: "",
- DDLSD24: "",
- DDLSD25: "",
- DDLSD26: "",
- DDLSD27: "",
- DDLSD28: "",
- DDLSD29: "",
- DDLSD30: "",
- DDLSD31: "",
- DDLSD32: "",
- DDLSD33: "",
- DDLSD34: "",
- DDLSD35: "",
- };
- break;
- }
- tableData.value[index].push({
- deviceNo: no,
- deviceName: name,
- deviceType: type,
- data: data,
- operationId: store.odersData.operationId,
- operationName: store.processInfo.operationName,
- processId: store.scanInfo.id,
- seqNo: store.scanInfo.seqNo,
- workOrderCode: store.odersData.workOrderCode,
- index: tableData.value[index].length,
- addStatus: true,
- updateStatus: true,
- });
- };
- const tableKey = ref(false);
- const getData = async () => {
- const res = await getScrewdriverData();
- materialsData.value = res.data;
- materialsData.value.forEach((item, index) => {
- pageS.value.push({ ...page });
- getAcquisitionDatas(item.deviceNo, index);
- });
- };
- const paginationChange = (index1) => {
- materialsData.value.forEach((item, index) => {
- if (index == index1) {
- setAcquisitionDatas(item.deviceNo, index);
- }
- });
- };
- const getAcquisitionDatas = async (No, index) => {
- const res = await getAcquisitionData({
- deviceNo: No,
- operationId: store.odersData.operationId,
- pageNo: pageS.value[index].pageNo,
- pageSize: pageS.value[index].pageSize,
- processId: store.scanInfo.id,
- });
- pageS.value[index].total = res.data.totalCount;
- res.data.records.forEach((item, index) => {
- item.resdata = item.data;
- item.data = JSON.parse(item.data);
- item.updateStatus = false;
- item.index = index;
- });
- tableData.value[index] = res.data.records;
- };
- const setAcquisitionDatas = async (No, index) => {
- const res = await getAcquisitionData({
- deviceNo: No,
- operationId: store.odersData.operationId,
- pageNo: pageS.value[index].pageNo,
- pageSize: pageS.value[index].pageSize,
- processId: store.scanInfo.id,
- });
- pageS.value[index].total = res.data.totalCount;
- res.data.records.forEach((item, index) => {
- item.resdata = item.data;
- item.data = JSON.parse(item.data);
- item.updateStatus = false;
- item.index = index;
- });
- tableData.value[index] = res.data.records;
- };
- const DDLSDTableData = ref([]);
- const pageS = ref([]);
- const page = {
- pageSize: 10,
- pageNo: 1,
- total: 0,
- };
- onMounted(async () => {
- await getData();
- getTask();
- });
- emitter.on(EventsNames.GETDATA_DDLSD, (name) => {
- materialsData.value.forEach((item, index) => {
- if (item.deviceType == "DDLSD" && item.deviceNo == name) {
- setAcquisitionDatas(item.deviceNo, index);
- }
- });
- });
- emitter.on(EventsNames.GETDATA_YBKC, (name) => {
- materialsData.value.forEach((item, index) => {
- if (item.deviceType == "YBKC" && item.deviceNo == name) {
- setAcquisitionDatas(item.deviceNo, index);
- }
- });
- });
- emitter.on(EventsNames.GETDATA_GDC, (name) => {
- materialsData.value.forEach((item, index) => {
- if (item.deviceType == "GDC" && item.deviceNo == name) {
- setAcquisitionDatas(item.deviceNo, index);
- }
- });
- });
- emitter.on(EventsNames.GETDATA_WKDLT, (name) => {
- materialsData.value.forEach((item, index) => {
- if (item.deviceType == "WKDLT" && item.deviceNo == name) {
- setAcquisitionDatas(item.deviceNo, index);
- }
- });
- });
- </script>
- <style lang="scss" scoped>
- :deep(.el-collapse-item) {
- }
- :deep(.el-collapse-item__wrap) {
- background-color: black;
- }
- .diviceName {
- color: var(--ohos-text);
- }
- .ces {
- font-size: 18px;
- height: 40px;
- }
- .containerBox {
- padding: 20px;
- border-radius: 16px !important;
- overflow: hidden;
- }
- :deep(.el-collapse-item__header) {
- background-color: var(--ohos-box-bg) !important;
- padding: 0 20px;
- height: 80px;
- }
- :deep(.el-badge) {
- font-size: $f24;
- }
- :deep(.el-collapse-item__header) {
- font-size: $f24;
- }
- :deep(.el-pagination) {
- span {
- font-weight: 600 !important;
- }
- }
- :deep(.el-collapse-item__wrap) {
- padding: 20px;
- border: 1px solid var(--ohos-box-bg);
- }
- .opear {
- font-size: 16px;
- margin-right: 5px;
- cursor: pointer;
- }
- .round {
- width: 20px;
- height: 20px;
- border-radius: 10px;
- background-color: red;
- }
- .green {
- background-color: green;
- }
- </style>
|