lynn 7 months ago
commit 89c9c06392

@ -49,3 +49,28 @@ export function realTableIndex() {
url: '/api/admin/custom-form/real-table-index'
})
}
export function realTableShow(params) {
return request({
method: "get",
url: '/api/admin/custom-form/real-table-show',
params
})
}
export function relationDestroy(params) {
return request({
method: 'get',
url: '/api/admin/custom-form/relation-destroy',
params
})
}
export function clone (params) {
return request({
method: 'get',
url: '/api/admin/custom-form/clone-table',
params
})
}

@ -2,6 +2,24 @@
<div>
<xy-dialog ref="dialog" :width='70' :is-show.sync="isShow" type="form" :title="type==='add'?'新增':'编辑'"
:form="form" :rules="rules" @submit="submit">
<template v-slot:storehouses_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>仓库类型
</div>
<div class="xy-table-item-content">
<el-select v-model="form.storehouses_id" style="width:300px" placeholder="请选择">
<el-option
v-for="item in typelist"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:cangkumingcheng>
<div class="xy-table-item">
<div class="xy-table-item-label">
@ -149,11 +167,13 @@
tableName: 'materialstorages',
// flood_storages
areaList:[],
typelist:[],
mapparams: {
zoom: 11,
},
mapform: [],
form: {
storehouses_id:'',
cangkumingcheng: '',
cangkubianma: '',
suozaiquyu: '',
@ -168,6 +188,10 @@
quyu_id:''
},
rules: {
type_id: [{
required: true,
message: '请填写仓库名称'
}],
cangkumingcheng: [{
required: true,
message: '请填写仓库名称'

@ -5,11 +5,15 @@
<slot>
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
<Input v-model="select.keyword" style="width: 200px;margin-right: 10px;" placeholder="名称搜索" />
<Select @on-change="clearType" v-model="select.storehouses_id" style="width: 200px;margin-right: 10px;" placeholder="仓库类型" clearable>
<Option v-for="item in typelist" :key="item.id" :value="item.id">{{ item.name }}</Option>
</Select>
<Select @on-change="clearArea" v-model="select.area" style="width: 200px;margin-right: 10px;" placeholder="所在区域" clearable>
<Option v-for="item in areaList" :key="item.id" :value="item.id">{{ item.value }}</Option>
</Select>
<Button type="primary" @click="getList"></Button>
<Button type="primary" style="margin-left: 10px;" @click="$refs['addStorage'].type='add',
$refs['addStorage'].typelist = typelist,
$refs['addStorage'].isShow=true">添加</Button>
<!-- <Button icon="ios-add" type="primary" style="margin-left: 10px;"
@click="$refs['imports'].show()">导入</Button> -->
@ -25,7 +29,7 @@
<template slot-scope="scope">
<div>
<Button type="primary" size="small" @click="$refs['addStorage'].type='editor',
$refs['addStorage'].id=scope.row.id,
$refs['addStorage'].id=scope.row.id,$refs['addStorage'].typelist = typelist,
$refs['addStorage'].isShow=true">编辑</Button>
<Poptip transfer confirm title="确认要删除吗?" @on-ok="delRow(scope.row.id)">
<Button type="primary" style="margin-left: 10px;" size="small" ghost>删除</Button>
@ -46,6 +50,7 @@
index,
destroy
} from "@/api/system/baseForm.js"
import { getStorehouseTypeList } from '@/api/system/storehouseType'
import addStorage from './components/addStorage.vue'
import {
getparameteritem
@ -62,11 +67,13 @@
page_size: 10,
keyword: '',
table_name: 'materialstorages',
area:''
area:'',
storehouses_id:''
},
areaList:[],
total: 0,
list: [],
typelist:[],
table: [{
label: '序号',
type: 'index',
@ -75,9 +82,13 @@
}, {
label: '仓库名称',
prop: 'cangkumingcheng',
align: 'left',
fixed: 'left'
}, {
label: '仓库类型',
prop: 'storehouses_id_storehouses_id_relation.name',
align: 'center',
width: 120,
},
// {
// label: '',
@ -122,6 +133,7 @@
},
created() {
this.getArea()
this.getTypeList()
this.getList()
},
methods: {
@ -137,6 +149,22 @@
this.select.area = ''
}
},
clearType(e){
if(e){
this.select.storehouses_id = e
}else{
this.select.storehouses_id = ''
}
},
async getTypeList() {
const res = await getStorehouseTypeList({
page:1,
page_size:999
});
this.typelist = res.data
console.log("this.typelist",this.typelist)
},
async getList() {
const res = await index({
...this.select,
@ -148,6 +176,10 @@
key:'quyu_id',
op:'like',
value:this.select.area
},{
key:'storehouses_id',
op:'eq',
value:this.select.storehouses_id
}],
})
this.list = res.data

@ -0,0 +1,330 @@
<template>
<div>
<el-drawer direction="rtl"
title="关联"
:visible.sync="dialogVisible"
size="58%"
:before-close="(done) => {
$confirm('确认关闭?').then(_ => { done() });
}">
<template>
<div style="padding: 20px;">
<el-button size="small" type="primary" icon="el-icon-plus" @click="list.push({ link_table_name: '',local_key: '',foreign_key: '',link_relation: '' })"></el-button>
<xy-table
style="margin-top: 10px;"
:auths="[]"
size="small"
:is-page="false"
:list="list"
:table-item="table"
>
</xy-table>
</div>
</template>
</el-drawer>
</div>
</template>
<script>
import { realTableShow, realTableIndex, save, show, relationDestroy, update } from "@/api/system/customForm";
import {listparameter} from "@/api/system/dictionary";
export default {
data() {
return {
id: '',
copyTable: {},
dialogVisible: false,
tableName: "",
localFields: {},
realTables: [],
foreignFields: [],
parameters: [], //
list: [],
table: [
{
prop: 'custom_form_field',
label: '对应映射字段',
customFn: (row) => {
return (
<el-select size="mini"
value={ row.custom_form_field }
on={{
['change']:e => {
this.$set(row,'custom_form_field',e);
}
}}>
{
this.localFields.map(i => {
return (
<el-option value={ i.field } label={ i.name }></el-option>
)
})
}
</el-select>
);
},
},
{
prop: "local_key",
label: "关联本地字段",
customFn: (row) => {
return (
<el-select size="mini"
value={ row.local_key }
on={{
['change']:e => {
row.local_key = e
}
}}>
{
[{field:'id',name:'id'},...this.localFields].map(i => {
return (
<el-option value={ i.field } label={ i.name }></el-option>
)
})
}
</el-select>
);
},
},
{
prop: 'link_table',
label: '关联表',
customFn: (row) => {
return (
<el-select size="mini"
clearable={true}
value={row.link_table_name}
on={{
['change']:async e => {
row.link_table_name = e
if (e) {
this.foreignFields = await this.getFields(e)
}
}
}}>
{
this.realTables.map(i => {
return (
<el-option value={i} label={i}></el-option>
)
})
}
</el-select>
);
},
},
{
prop: 'parameter_id',
label: '关联数据字典',
customFn: (row) => {
return (
<el-select size="mini"
clearable={true}
value={row.parameter_id}
on={{
['change']:async e => {
row.parameter_id = e
if (e) {
this.foreignFields = await this.getFields('parameters')
}
}
}}>
{
this.parameters.map(i => {
return (
<el-option value={i.id} label={i.name}></el-option>
)
})
}
</el-select>
);
},
},
{
prop: "foreign_key",
label: "关联表字段",
customFn: (row) => {
return (
<el-select size="mini"
value={row.foreign_key}
on={{
['change']:e => {
row.foreign_key = e
}
}}>
{(() => {
let dom = [];
for (let key in this.foreignFields) {
dom.push(<el-option label={key} value={key}></el-option>);
}
return dom;
})()}
</el-select>
);
},
},
{
prop: 'link_relation',
label: '关联方式',
customFn: (row) => {
return (
<el-select size="mini"
value={row.link_relation}
on={{
['change']:e => {
row.link_relation = e
}
}}>
{
[
{ value: 'newHasOne', label: '一对一' },
{ value: 'newHasMany', label: '一对多' },
].map(i => {
return (
<el-option value={i.value} label={i.label}></el-option>
)
})
}
</el-select>
);
},
},
{
prop: 'operate',
label: '操作',
width: 180,
align: 'left',
customFn:(row, scope) => {
return [(
<el-button type='primary'
size="mini"
style={{
'margin-right': '6px'
}}
on={{
['click']:e => {
this.copyTable.relation = this.list
save(this.copyTable).then(res => {
this.getDetail()
update({ id: this.copyTable.id })
})
}
}}> </el-button>
),(
<el-popover width="180"
trigger="hover"
scopedSlots={{
"default": () => {
return (
<div>
<p style={{'padding-bottom':'10px'}}>确定要删除吗</p>
<div style={{"text-align":"right","margin":"0"}}>
<el-button size="mini"
type="text"
on={{
['click']:e => {
}
}}>取消</el-button>
<el-button type="primary"
size="mini"
on={{
['click']:() => {
if(row.id){
relationDestroy({ id: row.id }).then(res => {
this.getDetail()
update({ id: this.copyTable.id })
})
} else {
this.list.splice(scope.$index, 1)
}
}
}}>确定</el-button>
</div>
</div>
)
},
"reference":() => {
return (
<el-button
type="danger"
size="mini"
>
删除
</el-button>
)
}
}}>
</el-popover>
)]
}
}
],
};
},
methods: {
show() {
this.dialogVisible = true;
},
hide() {
this.dialogVisible = false;
},
set(key = [], value = []) {
if (key instanceof Array) {
key.forEach((key, index) => {
this[key] = value[index] ?? "";
});
}
if (typeof key === "string") {
this[key] = value;
}
},
async getParameters() {
const res = await listparameter({ page: 1, page_size: 999 });
this.parameters = res.data;
},
async getFields(tableName) {
const res = await realTableShow({ table_name: tableName });
console.log(res);
res['id'] = 'integer';
return res || {};
},
async getRealTables() {
const res = await realTableIndex();
this.realTables = res;
},
async getDetail() {
const res = await show({ id: this.copyTable?.id })
this.localFields = res.fields || []
this.list = res.relation.map(i => {
return i
})
},
submit(scope) {
console.log(scope)
}
},
computed: {},
watch: {
async dialogVisible(newVal) {
if (newVal) {
//this.localFields = await this.getFields(this.tableName);
await this.getDetail();
}
},
},
created() {
this.getParameters();
this.getRealTables();
},
};
</script>
<style scoped lang="scss"></style>

@ -3,12 +3,28 @@
<!-- 查询配置 -->
<div>
<div ref="lxHeader">
<LxHeader icon="md-apps" text="自定义表单" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<LxHeader
icon="md-apps"
text="自定义表单"
style="margin-bottom: 10px; border: 0px; margin-top: 15px"
>
<div slot="content"></div>
<slot>
<div>
<Button type="primary" style="margin-left: 10px" @click="$refs['xyTable'].getTableData()"></Button>
<Button type="primary" style="margin-left: 10px" @click="$refs['addForm'].type = 'add',$refs['addForm'].show()">新增</Button>
<Button
type="primary"
style="margin-left: 10px"
@click="$refs['xyTable'].getTableData()"
>查询</Button
>
<Button
type="primary"
style="margin-left: 10px"
@click="
($refs['addForm'].type = 'add'), $refs['addForm'].show()
"
>新增</Button
>
</div>
</slot>
</LxHeader>
@ -22,75 +38,162 @@
:destroy-action="destroy"
:border="true"
:table-item="table"
@editor="row => {
@editor="
(row) => {
$refs['addForm'].setType('editor');
$refs['addForm'].setId(row.id);
$refs['addForm'].show();
}">
}
"
>
<template #setting="scope">
<Button type="primary"
<Button
type="primary"
size="small"
style="margin-right: 6px"
@click="
$refs['formEditor'].set(
['custom_form_id', 'custom_form'],
[scope.row.id, scope.row]
),
$refs['formEditor'].show()
"
>字段</Button
>
<Button
type="primary"
size="small"
@click="$refs['formEditor'].set(['custom_form_id','custom_form'],[scope.row.id,scope.row]),$refs['formEditor'].show()">字段</Button>
style="margin-right: 6px"
@click="
$refs['linkWith'].set(
['tableName', 'copyTable'],
[scope.row.table_name, deepCopy(scope.row)]
),
$refs['linkWith'].show()
"
>关联</Button
>
<Button
type="primary"
size="small"
style="margin-right: 6px"
@click="clone(scope)"
>克隆</Button
>
</template>
</xy-table>
<addForm ref="addForm" @refresh="$refs['xyTable'].getTableData()"></addForm>
<formEditor ref="formEditor"></formEditor>
<linkWith ref="linkWith"></linkWith>
</div>
</template>
<script>
import { index,destroy } from '@/api/system/customForm'
import { index, destroy, clone } from "@/api/system/customForm";
import { authMixin } from "@/mixin/authMixin";
import LxHeader from "@/components/LxHeader/index.vue";
import addForm from "./components/addForm.vue";
import formEditor from "@/views/system/components/formEditor.vue";
import linkWith from "@/views/system/components/linkWith.vue";
import { deepCopy } from "@/utils";
export default {
components: {
LxHeader,addForm,formEditor
LxHeader,
addForm,
formEditor,
linkWith,
},
mixins: [authMixin],
data() {
return {
inputValue: "",
select: {
page: 1,
page_size:10
page_size: 10,
},
list: [],
table: [
{
type: 'index',
label:'编号',
width:100
type: "index",
label: "编号",
width: 100,
},
{
prop:'table_name',
label:'表名',
prop: "table_name",
label: "表名",
//width:180,
sortable:'custom',
sortable: "custom",
},
{
prop:'name',
label:'名称',
prop: "name",
label: "名称",
// width:200,
sortable:'custom',
sortable: "custom",
},
]
}
],
};
},
methods: {
index,destroy,
deepCopy,
index,
destroy,
clone ({ row }) {
const h = this.$createElement;
this.$msgbox({
title: "表克隆",
message: h("div", [
h("span", `克隆表:${row.name}`)
]),
showCancelButton: true,
beforeClose: (action, instance, done) => {
if (action === "confirm") {
instance.confirmButtonLoading = true;
instance.confirmButtonText = "执行中...";
clone({
table_name: row.table_name
}).then(res => {
instance.confirmButtonLoading = false;
done();
this.$refs['xyTable'].getTableData()
this.$message({
type: 'success',
message: '克隆成功'
})
}).catch(err => {
instance.confirmButtonLoading = false;
})
} else {
done();
}
},
}).then((action) => {
});
},
},
computed: {},
mounted() {
}
}
mounted() {},
};
</script>
<style scoped lang="scss">
.form-input {
display: block;
background-color: #fff;
border-radius: 4px;
border: 1px solid #dcdfe6;
color: #606266;
line-height: 2;
transition: all 0.2s;
padding: 0 15px;
margin-top: 10px;
&:hover {
border-color: #c0c4cc;
}
&:focus {
outline: none;
border-color: #1d2088;
}
}
</style>

Loading…
Cancel
Save