|
@@ -17,6 +17,8 @@
|
|
|
<span class="text-orange">*编号更改后,所有已生成的资料删除编号内容,保存后重新自动生成。</span>
|
|
|
</template>
|
|
|
<template #extra>
|
|
|
+ <span class="mr-1">生成预览</span>
|
|
|
+ <el-input v-model="inputNum" style="width: 300px;" class="mr-1" />
|
|
|
<HcTooltip keys="tentative-basic-code-add">
|
|
|
<el-button
|
|
|
hc-btn
|
|
@@ -29,7 +31,7 @@
|
|
|
</HcTooltip>
|
|
|
|
|
|
<HcTooltip keys="tentative-basic-code-sort">
|
|
|
- <el-button hc-btn type="primary" color="#12C060" style="color: white;">
|
|
|
+ <el-button hc-btn type="primary" color="#12C060" style="color: white;" @click="sortFormClick">
|
|
|
<HcIcon name="arrow-up-down" />
|
|
|
<span>排序</span>
|
|
|
</el-button>
|
|
@@ -60,7 +62,7 @@
|
|
|
@selection-change="tableSelection"
|
|
|
>
|
|
|
<template #type="{ row }">
|
|
|
- <el-select v-if="row.isEdit" v-model="row.type" placeholder="请选择">
|
|
|
+ <el-select v-if="row.isEdit" v-model="row.rule" placeholder="请选择">
|
|
|
<el-option
|
|
|
v-for="item in typeOptions"
|
|
|
:key="item.key"
|
|
@@ -68,14 +70,14 @@
|
|
|
:value="item.key"
|
|
|
/>
|
|
|
</el-select>
|
|
|
- <span v-else>{{ getTypeLabel(row.type) }}</span>
|
|
|
+ <span v-else>{{ getTypeLabel(row.rule) }}</span>
|
|
|
</template>
|
|
|
<template #data="{ row }">
|
|
|
<el-input v-if="row.isEdit" v-model="row.data" placeholder="请输入数据" />
|
|
|
<span v-else>{{ row.data }}</span>
|
|
|
</template>
|
|
|
<template #isAutoIncrement="{ row }">
|
|
|
- <el-checkbox v-if="row?.type === '6'" v-model="row.isAutoIncrement" :disabled="!row.isEdit">是否自增</el-checkbox>
|
|
|
+ <el-checkbox v-if="row?.rule === 6" v-model="row.isAutoIncrement" :disabled="!row.isEdit" :true-value="1" :false-value="0" />
|
|
|
</template>
|
|
|
<template #action="{ row }">
|
|
|
<el-button
|
|
@@ -109,16 +111,49 @@
|
|
|
</template>
|
|
|
</HcTable>
|
|
|
</hc-card>
|
|
|
+
|
|
|
+ <!-- 表单排序 -->
|
|
|
+ <hc-new-dialog
|
|
|
+ v-model="sortFormShow"
|
|
|
+ is-table
|
|
|
+ title="排序"
|
|
|
+ widths="800px"
|
|
|
+ is-footer-center
|
|
|
+ @close="sortFormClose"
|
|
|
+ >
|
|
|
+ <hc-table
|
|
|
+ ref="tableSortFormRef"
|
|
|
+ :column="tableSortFormColumn"
|
|
|
+ :datas="tableSortFormData"
|
|
|
+ is-row-drop
|
|
|
+ is-sort
|
|
|
+ quick-sort
|
|
|
+ @row-drop="sortFormDropTap"
|
|
|
+ @row-sort="rowSortFormTap"
|
|
|
+ />
|
|
|
+ <template #footer>
|
|
|
+ <el-button hc-btn @click="sortFormClose">取消</el-button>
|
|
|
+ <el-button
|
|
|
+ hc-btn
|
|
|
+ type="primary"
|
|
|
+ :loading="sortFormLoading"
|
|
|
+ @click="sortFormSubmit"
|
|
|
+ >
|
|
|
+ 提交
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </hc-new-dialog>
|
|
|
</hc-body>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref } from 'vue'
|
|
|
+import { nextTick, onMounted, ref } from 'vue'
|
|
|
import { getDictionary } from '~api/other'
|
|
|
import { arrToId, getArrValue } from 'js-fast-way'
|
|
|
import dataApi from '~api/basic/code'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import { HcDelMsg } from 'hc-vue3-ui'
|
|
|
+import { deepClone } from 'js-fast-way'
|
|
|
const store = useAppStore()
|
|
|
const projectId = ref(store.getProjectId)
|
|
|
const contractId = ref(store.getContractId)
|
|
@@ -135,6 +170,8 @@ const menuOptions = ref([
|
|
|
{ key: '4', label: '记录表编号' },
|
|
|
{ key: '5', label: '报告表编号' },
|
|
|
])
|
|
|
+const inputNum = ref('')
|
|
|
+
|
|
|
//左侧菜单
|
|
|
const menuProps = {
|
|
|
key: 'key',
|
|
@@ -151,10 +188,12 @@ const getTypeOptions = async ()=>{
|
|
|
for (let i = 0; i < newData.length; i++) {
|
|
|
newArr.push({
|
|
|
label: newData[i]['dictValue'],
|
|
|
- key: newData[i]['dictKey'],
|
|
|
+ key: Number(newData[i]['dictKey']),
|
|
|
})
|
|
|
}
|
|
|
typeOptions.value = newArr
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
// 查找typeOptions中对应的label
|
|
|
const getTypeLabel = (typeKey) => {
|
|
@@ -189,7 +228,7 @@ const getTableData = async () => {
|
|
|
//处理数据
|
|
|
tableLoad.value = false
|
|
|
if (!error && code === 200) {
|
|
|
- tableData.value = getArrValue(data['records'])
|
|
|
+ tableData.value = getArrValue(data['list'])
|
|
|
|
|
|
} else {
|
|
|
tableData.value = []
|
|
@@ -211,21 +250,42 @@ const saveLoading = ref(false)
|
|
|
// 保存行
|
|
|
const handleSave = async (row) => {
|
|
|
saveLoading.value = true
|
|
|
- const { error, code, msg } = await dataApi.save({
|
|
|
- ...row,
|
|
|
- projectId: projectId.value,
|
|
|
- contractId: contractId.value,
|
|
|
- })
|
|
|
- //处理数据
|
|
|
- saveLoading.value = false
|
|
|
- if (!error && code === 200) {
|
|
|
- window?.$message?.success(msg)
|
|
|
- row.isEdit = false
|
|
|
-
|
|
|
+ if (!row.id) {
|
|
|
+ const { error, code, msg, data } = await dataApi.save({
|
|
|
+ ...row,
|
|
|
+ projectId: projectId.value,
|
|
|
+ contractId: contractId.value,
|
|
|
+ type: menuKey.value,
|
|
|
+ })
|
|
|
+ //处理数据
|
|
|
+ saveLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window?.$message?.success(msg)
|
|
|
+ row.isEdit = false
|
|
|
+ inputNum.value = data
|
|
|
+
|
|
|
+ getTableData()
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const { error, code, msg, data } = await dataApi.update({
|
|
|
+ ...row,
|
|
|
+ projectId: projectId.value,
|
|
|
+ contractId: contractId.value,
|
|
|
+ type: menuKey.value,
|
|
|
+ })
|
|
|
+ //处理数据
|
|
|
+ saveLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window?.$message?.success(msg)
|
|
|
+ row.isEdit = false
|
|
|
+ inputNum.value = data
|
|
|
+
|
|
|
+ getTableData()
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- getTableData()
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -235,14 +295,14 @@ const handleDelete = async ({ item }, resolve) => {
|
|
|
}
|
|
|
//删除请求
|
|
|
const delData = async (id) => {
|
|
|
- const { error, code, msg } = await dataApi.delData({
|
|
|
- contractId: contractId.value,
|
|
|
- pkeyId: id,
|
|
|
+ const { error, code, msg, data } = await dataApi.remove({
|
|
|
+ ids:id,
|
|
|
|
|
|
}, false)
|
|
|
//判断状态
|
|
|
if (!error && code === 200) {
|
|
|
window?.$message?.success(msg)
|
|
|
+ inputNum.value = data
|
|
|
getTableData()
|
|
|
} else {
|
|
|
window?.$message?.error(msg)
|
|
@@ -279,8 +339,73 @@ const resetModalClick = async () => {
|
|
|
if (!error && code === 200) {
|
|
|
window?.$message?.success(msg)
|
|
|
getTableData()
|
|
|
+ inputNum.value = data
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-</script>
|
|
|
+//排序
|
|
|
+const sortFormShow = ref(false)
|
|
|
+const tableSortFormRef = ref(null)
|
|
|
+const tableSortFormData = ref([])
|
|
|
+const sortFormLoading = ref(false)
|
|
|
+const tableSortFormColumn = ref([
|
|
|
+ { key: 'type', name: '规则' },
|
|
|
+ { key: 'data', name: '数据填充' },
|
|
|
+ { key: 'isAutoIncrement', name: '是否自增' },
|
|
|
+ { key: 'action', name: '操作' },
|
|
|
+])
|
|
|
+const sortFormClick = () => {
|
|
|
+ sortFormShow.value = true
|
|
|
+ tableSortFormData.value = deepClone(tableData.value)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 行拖拽
|
|
|
+const sortFormDropTap = (rows) => {
|
|
|
+ tableSortFormData.value = [] // 先清空,否则排序会异常
|
|
|
+ nextTick(() => {
|
|
|
+ tableSortFormRef.value?.setData(rows)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 点击排序
|
|
|
+const rowSortFormTap = (rows) => {
|
|
|
+ tableSortFormData.value = [] // 先清空,否则排序会异常
|
|
|
+ nextTick(() => {
|
|
|
+ tableSortFormData.value = rows
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//关闭排序
|
|
|
+const sortFormClose = () => {
|
|
|
+ sortFormShow.value = false
|
|
|
+ sortFormLoading.value = false
|
|
|
+ tableSortFormData.value = []
|
|
|
+}
|
|
|
+const sortFormSubmit = async () => {
|
|
|
+
|
|
|
+ //发起请求
|
|
|
+ sortFormLoading.value = true
|
|
|
+ const { error, code, msg, data } = await dataApi.sort(
|
|
|
+ tableSortFormData.value,
|
|
|
+
|
|
|
+ )
|
|
|
+ sortFormLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window?.$message?.success(msg)
|
|
|
+ inputNum.value = data
|
|
|
+
|
|
|
+ getTableData()
|
|
|
+ sortFormClose()
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.wrap-text {
|
|
|
+ white-space: normal; /* 或者使用 pre-wrap */
|
|
|
+ word-wrap: break-word; /* 防止长单词不换行 */
|
|
|
+}
|
|
|
+</style>
|