|
@@ -21,18 +21,18 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, getCurrentInstance } from "vue";
|
|
|
-import { useCrud } from "@/hooks/userCrud";
|
|
|
+import {ref, getCurrentInstance} from "vue";
|
|
|
+import {useCrud} from "@/hooks/userCrud";
|
|
|
|
|
|
// 传入一个url,后面不带/
|
|
|
-const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
|
|
|
+const {form, data, option, search, page, toDeleteIds, Methords, Utils} =
|
|
|
useCrud({
|
|
|
src: "/api/v1/attendanceStatistics",
|
|
|
});
|
|
|
-const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
|
|
|
+const {dataList, createRow, updateRow, deleteRow, searchChange, resetChange} =
|
|
|
Methords; //增删改查
|
|
|
-const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
|
|
|
-const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
|
|
|
+const {selectionChange, multipleDelete} = Methords; //选中和批量删除事件
|
|
|
+const {checkBtnPerm, downloadTemplate, exportData} = Utils; //按钮权限等工具
|
|
|
const deptTypes = ref([]);
|
|
|
const crudRef = ref(null); //crudRef.value 获取avue-crud对象
|
|
|
|
|
@@ -48,17 +48,6 @@ const startCreat = () => {
|
|
|
reserveSelection: true,
|
|
|
});
|
|
|
};
|
|
|
-const addNumbers = () => {
|
|
|
- nextTick(() => {
|
|
|
- if (productionLineRef.value) {
|
|
|
- productionLineRef.value?.mergeOption({
|
|
|
- selection: true,
|
|
|
- reserveSelection: true,
|
|
|
- });
|
|
|
- productionLineRef.value.startSelect();
|
|
|
- }
|
|
|
- });
|
|
|
-};
|
|
|
// 设置表格列或者其他自定义的option
|
|
|
option.value = Object.assign(option.value, {
|
|
|
searchEnter: false,
|
|
@@ -72,27 +61,39 @@ option.value = Object.assign(option.value, {
|
|
|
editBtn: false,
|
|
|
rowKey: "id",
|
|
|
column: [
|
|
|
+ // {
|
|
|
+ // label: "择班组信息",
|
|
|
+ // prop: "toSelect",
|
|
|
+ // hide: true,
|
|
|
+ // type: "tree",
|
|
|
+ // dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/dept/orgTree",
|
|
|
+ // // dicMethod: "post",
|
|
|
+ // span: 24,
|
|
|
+ // props: {
|
|
|
+ // label: "deptName", // 下拉菜单显示的字段
|
|
|
+ // value: "deptCode", // 下拉菜单值的字段
|
|
|
+ // },
|
|
|
+ // change: (row) => {
|
|
|
+ // if (row && row.item) {
|
|
|
+ // form.value.deptName = row.item.deptName;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // },
|
|
|
{
|
|
|
- label: "择班组信息",
|
|
|
- prop: "toSelect",
|
|
|
- hide: true,
|
|
|
- type: "tree",
|
|
|
- dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/dept/orgTree",
|
|
|
- // dicMethod: "post",
|
|
|
- span: 24,
|
|
|
+ label: "班组名称",
|
|
|
+ prop: "deptName",
|
|
|
+ type: "select",
|
|
|
+ dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/dept/deptList?parentId=10",
|
|
|
props: {
|
|
|
- label: "deptName", // 下拉菜单显示的字段
|
|
|
- value: "deptCode", // 下拉菜单值的字段
|
|
|
+ label: "deptName",
|
|
|
+ value: "deptName",
|
|
|
},
|
|
|
change: (row) => {
|
|
|
if (row && row.item) {
|
|
|
form.value.deptName = row.item.deptName;
|
|
|
+ form.value.deptNum = row.item.deptNum;
|
|
|
}
|
|
|
},
|
|
|
- },
|
|
|
- {
|
|
|
- label: "班组名称",
|
|
|
- prop: "deptName",
|
|
|
search: true,
|
|
|
overHidden: true,
|
|
|
rules: [
|
|
@@ -150,14 +151,24 @@ option.value = Object.assign(option.value, {
|
|
|
trigger: "trigger",
|
|
|
},
|
|
|
],
|
|
|
- blur: (row) => {
|
|
|
- form.value.attendanceRate = "改这个地方";
|
|
|
+ blur: () => {
|
|
|
+ // 检查两个字段是否都有值(不为 null/undefined/空字符串/0)
|
|
|
+ if (form.value.practicalNum != null && form.value.answerNum != null) {
|
|
|
+ // 额外检查 answerNum 不能为 0(避免除以零)
|
|
|
+ if (form.value.answerNum !== 0) {
|
|
|
+ form.value.attendanceRate = (form.value.practicalNum / form.value.answerNum * 100).toFixed(2);
|
|
|
+ } else {
|
|
|
+ form.value.attendanceRate = 0; // 或其他默认值
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果任一字段为空,不执行计算(保持 attendanceRate 原值或清空)
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
- label: "出勤率",
|
|
|
+ label: "出勤率(%)",
|
|
|
prop: "attendanceRate",
|
|
|
search: false,
|
|
|
+
|
|
|
overHidden: true,
|
|
|
},
|
|
|
{
|
|
@@ -175,17 +186,5 @@ const onBeforeOpen = (done) => {
|
|
|
form.value.dtos = [];
|
|
|
done();
|
|
|
};
|
|
|
-const onSelectedFinish = (selectedValue) => {
|
|
|
- let toAddRow = JSON.parse(JSON.stringify(selectedValue));
|
|
|
- let tableData_ids = tableData.value.map((item) => item.id);
|
|
|
- toAddRow = toAddRow.filter((item) => {
|
|
|
- return tableData_ids.indexOf(item.id) === -1;
|
|
|
- });
|
|
|
- tableData.value.push(...toAddRow);
|
|
|
- form.value.dtos = tableData.value;
|
|
|
-};
|
|
|
-const deleteTableRow = (index: number) => {
|
|
|
- tableData.value.splice(index, 1);
|
|
|
- form.value.dtos = tableData.value;
|
|
|
-};
|
|
|
+
|
|
|
</script>
|