This commit is contained in:
qsh
2024-08-12 17:54:34 +08:00
parent 1be86c7699
commit db22a8ae8a
9 changed files with 345 additions and 77 deletions

View File

@@ -52,6 +52,13 @@
<template #actionMore>
<el-button @click="getTableList" v-hasPermi="['clue:order:search']"> 搜索 </el-button>
<el-button @click="resetQuery" v-hasPermi="['clue:order:reset']"> 重置 </el-button>
<el-button
type="primary"
@click="handleBatchUpdateInstall"
v-hasPermi="['clue:order:reset']"
>
批量修改安装状态
</el-button>
</template>
</Search>
</div>
@@ -61,58 +68,88 @@
class="mt-10px"
v-model:tableObject="tableObject"
:tableColumns="allSchemas.tableColumns"
rowkey="signId"
:expandRowKeys="expendRows"
@get-list="getTableList"
@get-checked-columns="getCheckedColumns"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="60" />
<el-table-column type="expand">
<template #default="{ row }">
<div class="p-10px flex justify-center">
<el-table :data="row.signProducts" stripe style="width: 900px">
<el-table-column prop="productName" label="成交产品" />
<el-table-column prop="specsName" label="产品规格" width="100px" />
<el-table-column prop="signNum" label="成交数量" width="90px" />
<el-table-column prop="remark" label="成交备注" />
<el-table-column label="发货状态" prop="sendState" width="90px">
<template #default="scope">
<el-tag
:type="scope.row.sendState == '待发货' ? 'danger' : 'success'"
size="small"
>
{{ scope.row.sendState }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="发货备注" width="100px">
<template #default="scope">
<el-popover
placement="top"
width="500px"
trigger="click"
v-if="scope.row.warehouseName && scope.row.sendRemark"
>
<template #reference>
<el-button type="primary" style="padding: 0" text>点击查看</el-button>
</template>
<div v-dompurify-html="scope.row.sendRemark"></div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="操作" width="100px">
<template #default="scope">
<el-button
type="primary"
class="mr-10px"
link
:disabled="scope.row.sendState == '已发货'"
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:send']"
@click="handleDelivery(scope.row)"
>
发货
</el-button>
</template>
</el-table-column>
</el-table>
<VueDraggable
target="tbody"
v-model="row.signProducts"
:animation="150"
@end="onDragEnd"
style="width: 100%"
>
<el-table
:data="row.signProducts"
row-key="id"
stripe
style="width: 80%; margin: 0 auto"
>
<el-table-column prop="productName" label="成交产品" />
<el-table-column prop="specsName" label="产品规格" />
<el-table-column prop="signNum" label="成交数量" width="90px" />
<el-table-column prop="remark" label="成交备注" width="100px" />
<el-table-column label="生产状态" width="160px">
<template #default="scope">
<el-switch
v-model="scope.row.isProduced"
:active-value="true"
:inactive-value="false"
active-text="已生产"
inactive-text="待生产"
size="small"
@change="handleChangeProdoce(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="发货状态" prop="sendState" width="90px">
<template #default="scope">
<el-tag
:type="scope.row.sendState == '待发货' ? 'danger' : 'success'"
size="small"
>
{{ scope.row.sendState }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="发货备注" width="100px">
<template #default="scope">
<el-popover
placement="top"
width="500px"
trigger="click"
v-if="scope.row.warehouseName && scope.row.sendRemark"
>
<template #reference>
<el-button type="primary" style="padding: 0" text>点击查看</el-button>
</template>
<div v-dompurify-html="scope.row.sendRemark"></div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="操作" width="100px">
<template #default="scope">
<el-button
type="primary"
class="mr-10px"
link
:disabled="scope.row.sendState == '已发货'"
style="padding: 0; margin-left: 0"
v-hasPermi="['clue:order:send']"
@click="handleDelivery(scope.row)"
>
发货
</el-button>
</template>
</el-table-column>
</el-table>
</VueDraggable>
</div>
</template>
</el-table-column>
@@ -217,6 +254,8 @@ import DialogDelivery from './DialogDelivery.vue'
import { removeNullField } from '@/utils'
import { formatDate } from '@/utils/formatTime'
import { ElMessageBox, ElOption, ElSelect } from 'element-plus'
import { VueDraggable } from 'vue-draggable-plus'
const userOptions = ref([])
const allUserOptions = ref([])
@@ -362,6 +401,96 @@ const deliveryDialog = ref()
function handleDelivery(row) {
deliveryDialog.value.open(row)
}
const batchIds = ref([])
function handleSelectionChange(val) {
batchIds.value = val.map((it) => it.signId)
}
const selectedValue = ref(undefined)
const installOptions = [
{ label: '待安装', value: 1 },
{ label: '已安装', value: 2 },
{ label: '无需安装', value: 3 }
]
const select = () =>
h(
ElSelect,
{
modelValue: selectedValue.value,
placeholder: '新状态',
'onUpdate:modelValue': (val) => {
selectedValue.value = val
}
},
() =>
installOptions.map((item) => {
return h(ElOption, { label: item.label, value: item.value })
})
)
function handleBatchUpdateInstall() {
if (batchIds.value.length) {
ElMessageBox({
title: '是否确认修改安装状态?',
message: select,
showCancelButton: true,
confirmButtonText: '确定',
cancelButtonText: '取消'
}).then(async (action) => {
// 处理用户点击确定或取消按钮后的逻辑
if (action == 'confirm') {
try {
// 发起修改状态
await SignApi.updateInstallStatus(batchIds.value, selectedValue.value)
message.success('修改成功')
// 刷新列表
await getTableList()
} catch (err) {
// 取消后,进行恢复按钮
console.log(err)
}
}
})
} else {
message.info('请选择表格行')
}
}
async function handleChangeProdoce(row) {
try {
// 修改状态的二次确认
await message.confirm('确认要修改生产状态吗?')
// 发起修改状态
await SignApi.updateProduceStatus({
signId: row.signId,
id: row.id,
isProduced: row.isProduced
})
message.success('修改成功')
// 刷新列表
getTableList()
} catch {
// 取消后,进行恢复按钮
row.isProduced = !row.isProduced
}
}
const expendRows = ref([])
async function onDragEnd(ev) {
try {
expendRows.value = [ev.data.signId]
const list = tableObject.value.tableList.find((it) => it.signId == ev.data.signId).signProducts
await SignApi.updateProduceSort(list.map((it) => it.id))
message.success('修改成功')
// 刷新列表
getTableList()
} catch (error) {
console.log(error)
getTableList()
}
}
</script>
<style lang="scss" scoped></style>