设置联合工时

dev
qiuhongwu 4 months ago
parent d34665f781
commit 3691830b08

@ -88,3 +88,8 @@ export const getTaskDispatchWarning = async (id) => {
export const getTaskDispatchWorkTimePage = async (params) => { export const getTaskDispatchWorkTimePage = async (params) => {
return await request.get({ url: `/biz/task-dispatch/page-work-time`, params }) return await request.get({ url: `/biz/task-dispatch/page-work-time`, params })
} }
//查询设置工时
export const getWorkTime = async (id) => {
return await request.get({ url: `/biz/task-dispatch-detail-ratio/page?detailOwnerId=` + id})
}

@ -423,8 +423,17 @@
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" align="center" min-width="100"> <el-table-column fixed="right" label="操作" align="center" min-width="120">
<template #default="scope"> <template #default="scope">
<el-button
v-if="'detail' != active && scope.row.procedureStatus == 0"
link
type="primary"
size="small"
@click.prevent="openratioDetail(scope.row, scope.$index)"
>
编辑
</el-button>
<el-button <el-button
v-if="'detail' != active && scope.row.procedureStatus == 0" v-if="'detail' != active && scope.row.procedureStatus == 0"
link link
@ -505,6 +514,7 @@
</el-card> </el-card>
<UserDialog ref="userDialogref" @success="handleuserClick" /> <UserDialog ref="userDialogref" @success="handleuserClick" />
<ProductFrom ref="productref" @success="handleproductClick" /> <ProductFrom ref="productref" @success="handleproductClick" />
<Ratiodialog ref="ratiodialogref" @success="handlratioClick" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -527,11 +537,12 @@ import { Search } from '@element-plus/icons-vue'
import * as ProcedureApi from '@/api/biz/procedure' import * as ProcedureApi from '@/api/biz/procedure'
import UserDialog from './userselect.vue' import UserDialog from './userselect.vue'
import ProductFrom from './productFrom.vue' import ProductFrom from './productFrom.vue'
import Ratiodialog from './ratiodialog.vue'
defineOptions({ name: 'TaskDispatchDetail' }) defineOptions({ name: 'TaskDispatchDetail' })
const goEasy: any = inject('goEasy') const goEasy: any = inject('goEasy')
const reload = inject('reload') const reload: any = inject('reload')
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const commonStore = useCommonStore() const commonStore = useCommonStore()
@ -636,12 +647,8 @@ const queryData = async (id?: number) => {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await TaskDispatchApi.getTaskDispatch(id) formData.value = await TaskDispatchApi.getTaskDispatch(id)
// formData.value.spec=await MaterialApi.getMaterial(formData.value.projectSubId)
formData.value.taskDispatchDetails = formData.value.taskDispatchDetails =
await TaskDispatchApi.getTaskDispatchDetailListByDispatchId(id) await TaskDispatchApi.getTaskDispatchDetailListByDispatchId(id)
// formData.value.bomCode = 'BOM-' + formData.value.projectSubCode
formData.value.taskDispatchDetails.forEach((item) => { formData.value.taskDispatchDetails.forEach((item) => {
const startDate = new Date(item.startTime) const startDate = new Date(item.startTime)
const endDate = new Date(item.endTime) const endDate = new Date(item.endTime)
@ -649,9 +656,8 @@ const queryData = async (id?: number) => {
const diffInMilliseconds = endDate.getTime() - startDate.getTime() const diffInMilliseconds = endDate.getTime() - startDate.getTime()
// //
const diffInDays = diffInMilliseconds / (1000 * 60 * 60 * 24) + 1 // const diffInDays = diffInMilliseconds / (1000 * 60 * 60 * 24) + 1 //
// console.log(`${diffInDays}`)
// console.log('', val.amount / diffInDays)
item.dailyCapacity = (item.amount / diffInDays).toFixed(2) item.dailyCapacity = (item.amount / diffInDays).toFixed(2)
item.ratioSettings = []
}) })
if (formData.value.dispatchStatus == 2) { if (formData.value.dispatchStatus == 2) {
@ -713,21 +719,6 @@ const submitForm = async (operate) => {
if (operate == 'SUBMIT') { if (operate == 'SUBMIT') {
jumpActive = 'detail' jumpActive = 'detail'
} }
// goEasy.publish({
// channel: 'mayJoysChannel',
// message: 'Hello, GoEasy!'
// })
// goEasy.pubsub.publish({
// channel: "mayJoysChannel",
// message: 'Hello, GoEasy!',
// // onSuccess: function () {
// // content.value = "";
// // console.log("send message success");
// // },
// // onFailed: function (error) {
// // unshiftMessage("" + error.code + " " + error.content);
// // }
// });
commonStore.setStore('active', jumpActive) commonStore.setStore('active', jumpActive)
commonStore.setStore('id', dataId) commonStore.setStore('id', dataId)
reload() reload()
@ -749,7 +740,8 @@ const onAddItem = () => {
status: 1, status: 1,
procedureStatus: 0, procedureStatus: 0,
dispatchId: undefined, dispatchId: undefined,
dailyCapacity: undefined dailyCapacity: undefined,
ratioSettings: []
} }
row.amount = formData.value.amount row.amount = formData.value.amount
row.dispatchId = formData.value.id row.dispatchId = formData.value.id
@ -765,6 +757,30 @@ const goback = () => {
router.back() router.back()
} }
//
const ratiodialogref = ref()
const openratioDetail = (val, index) => {
if (val.owners == undefined) {
message.error('请先选择责任人')
} else {
const datalist: any = []
// console.log(val.ratioSettings)
for (var i = 0; i < val.owners.length; i++) {
let ratios = val.ratioSettings[i] ? Reflect.get(val.ratioSettings[i], 'ratio') : undefined
datalist.push({
id: undefined,
detailOwnerId: val.id,
owner: val.owners[i],
ownerNames: val.ownerNames[i],
ratio: ratios
})
}
ratiodialogref.value.open(datalist, val.id, index)
}
}
/** 删除子项操作 */ /** 删除子项操作 */
const onDeleteItem = async (index) => { const onDeleteItem = async (index) => {
let deletedItems = formData.value.taskDispatchDetails.splice(index, 1) let deletedItems = formData.value.taskDispatchDetails.splice(index, 1)
@ -793,9 +809,8 @@ const handleuserClick = (val, index) => {
// console.log(formData.value.taskDispatchDetails[index].ownerNames); // console.log(formData.value.taskDispatchDetails[index].ownerNames);
} }
const handleproductClick = (vals) => { const handleproductClick = (vals) => {
console.log(vals)
vals.forEach((item) => { vals.forEach((item) => {
item.id=undefined item.id = undefined
item.amount = formData.value.amount item.amount = formData.value.amount
item.dispatchId = formData.value.id item.dispatchId = formData.value.id
item.deviceModel = item.procedureEquipId item.deviceModel = item.procedureEquipId
@ -805,6 +820,12 @@ const handleproductClick = (vals) => {
}) })
} }
const handlratioClick = (vals) => {
// console.log(vals)
formData.value.taskDispatchDetails[vals.index].ratioSettings = [...vals.ratioSettingss]
// console.log(formData.value.taskDispatchDetails[vals.index].ratioResults,'--------------');
}
const handleSelectedProcedure = async (row: any, newValue: any) => { const handleSelectedProcedure = async (row: any, newValue: any) => {
if (newValue) { if (newValue) {
row.procedureId = newValue.id row.procedureId = newValue.id

@ -0,0 +1,115 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle" style="width: 700px" v-loading="formLoading">
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="108px">
<el-form-item
label=""
prop="ratioSettingss"
v-for="(item, index) in formData.ratioSettingss"
:key="index"
>
<template #label>
<span>{{ item.ownerNames }}</span>
</template>
<el-input v-model="item.ratio" style="width: 240px" placeholder="请输入预计工时">
<template #append>%</template>
</el-input>
</el-form-item>
</el-form>
<template #footer>
<el-button type="" @click="out"> </el-button>
<el-button type="primary" @click="submitForm()" :loading="formLoading"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { getIntDictOptions, getStrDictOptions, DICT_TYPE, getDictLabel } from '@/utils/dict'
import * as TaskDispatchApi from '@/api/biz/taskdispatch'
import { FormRules } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import { set } from 'lodash-es'
import { it } from 'node:test'
defineOptions({ name: 'SystemDeptForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formData = ref({
index: undefined,
ratioSettingss: []
})
const formRules = reactive<FormRules>({
ratioSettingss: [{ required: true, message: '请输入预计工时', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const ownerIds = ref([])
const ownerNames = ref([])
const fuid = ref(undefined)
const workTimeIds = ref([])
const open = async (val, id, index) => {
resetForm()
formData.value.index = index
// console.log(val, index)
formData.value.ratioSettingss = val
if (id) {
const workTime = await TaskDispatchApi.getWorkTime(id)
// console.log(workTime.list, 'workTime.list')
workTime.list.forEach((item, index) => {
formData.value.ratioSettingss.forEach((e, index) => {
item.owner == e.owner ? (e.ratio = item.ratio) : e.ratio
item.owner == e.owner ? (e.id = item.id) : undefined
})
})
}
dialogVisible.value = true
dialogTitle.value = t('设置联合工时')
}
defineExpose({ open }) // open
const out = () => {
resetForm()
dialogVisible.value = false
}
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
await formRef.value.validate()
// ratio
const allRatiosValid = formData.value.ratioSettingss.every(
(item) => item.ratio !== undefined && item.ratio !== ''
)
if (!allRatiosValid) {
message.error('请输入全部员工预计工时')
return //
}
// console.log(formData.value.ratioSettingss, 'formData.value.ratioResults')
// //
formLoading.value = true
try {
const data = formData.value
dialogVisible.value = false
emit('success', data)
message.success(t('common.operationSuccess'))
//
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
index: undefined,
ratioSettingss: []
}
formRef.value?.resetFields()
}
</script>
Loading…
Cancel
Save