Commit a30afbdd by 刘泽志

3:21

parent 6e782b7d
......@@ -60,11 +60,11 @@ export function deleteField(fieldId) {
* @param excelId
* @returns {*}
*/
export function resetField(excelId){
export function resetField(excelId,year){
return request({
url: `${prefix}/reset`,
method: 'get',
params:{excelId}
params:{excelId,year}
})
}
......
......@@ -118,3 +118,18 @@ export function bindRule(data) {
data
})
}
/**
* 根据年份同步规则
* @param templateId
* @param year
* @returns {*}
*/
export function syncRuleByYear(templateId,year) {
return request({
url: `${prefix}/sync/year`,
method: 'get',
params:{templateId,year}
})
}
......@@ -120,3 +120,16 @@ export function deleteRuleByTemplate(ruleId,templateId) {
params:{ruleId,templateId}
})
}
/**
* 查询此类型模板的其它年份列表
* @param data
* @returns {*}
*/
export function queryOtherYears(data) {
return request({
url: `${prefix}/otherYears`,
method: 'post',
data
})
}
......@@ -211,7 +211,7 @@
<el-input-number v-model="fieldDialog.data.sort" :min="0" :precision="0"/>
</el-form-item>
<el-form-item label="数据库字段" prop="field">
<el-select v-model="fieldDialog.data.field" :popper-append-to-body="false" filterable>
<el-select v-model="fieldDialog.data.field" :popper-append-to-body="false" filterable clearable>
<el-option v-for="item in metaFieldDict" :key="item.value" :label="item.label" :value="item.value"
></el-option>
</el-select>
......@@ -250,10 +250,8 @@
</el-button>
<el-button type="success" @click="openFieldDialog">新增</el-button>
<el-button type="warning" @click="openQuicklyBind">快速绑定</el-button>
<el-button type="warning" @click="resetField" :loading="fieldDrawer.resetFieldLoading"
:disabled="!fieldDrawer.template.excelId"
>模板初始化
</el-button>
<el-button type="warning" @click="openSwitchYear('template')" :disabled="!fieldDrawer.template.excelId">模板初始化</el-button>
<el-button type="warning" @click="openSwitchYear('rule')">规则同步</el-button>
<el-button type="info" @click="createTable">物理表生成
</el-button>
</el-form-item>
......@@ -466,6 +464,17 @@
<el-button @click="orgListDialog.show = false">取 消</el-button>
</div>
</el-dialog>
<!--选择初始化年份-->
<el-dialog title="请选择同步年份" :visible.sync="otherYearDialog.show"
append-to-body width="300px" v-loading="otherYearDialog.loading"
>
<el-select v-model="otherYearDialog.year" >
<el-option v-for="item in otherYearDialog.list" :key="item" :value="item" :label="item"></el-option>
</el-select>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitOtherYear">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
......@@ -539,8 +548,7 @@ export default {
pageSize: 10,
total: 0
},
queryFieldLoading: false,
resetFieldLoading: false
queryFieldLoading: false
},
quicklyBindDialog: { // 字段dialog
show: false,
......@@ -576,6 +584,13 @@ export default {
title: '',
data: {}
},
otherYearDialog:{ // 模板重置选择年份数据
year: '',
show: false,
loading: false,
list:[],
type: ''
},
importLoading: false, // 导入数据loading
queryTemplateLoading: false, // 模板查询loading
queryTableLoading: false, // 查询数据表loading
......@@ -1107,21 +1122,40 @@ export default {
}
}).finally(_ => this.initTemplateDialog.loading = false)
},
// 重置字段信息
resetField() {
this.$confirm('此操作将覆盖原来设置的字段信息重新生成, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.fieldDrawer.resetFieldLoading = true
DataField.resetField(this.fieldDrawer.template.excelId).then(res => {
// 打开年份选择框
openSwitchYear(type){
this.otherYearDialog.show = true
this.otherYearDialog.type = type
this.otherYearDialog.year = null
DataTemplate.queryOtherYears(this.fieldDrawer.template)
.then(res=>{
this.otherYearDialog.list = res.data
})
},
// 提交同步年份信息
submitOtherYear() {
if (this.otherYearDialog.type === 'template'){
this.otherYearDialog.loading = true
DataField.resetField(this.fieldDrawer.template.excelId,
this.otherYearDialog.year).then(res => {
if (res.code === 200) {
this.$message.success('字段初始化成功')
this.otherYearDialog.show = false
this.queryFieldList()
}
}).finally(_ => this.fieldDrawer.resetFieldLoading = false)
})
}).finally(_ => this.otherYearDialog.loading = false)
}else {
if (this.otherYearDialog.year){
this.otherYearDialog.loading = true
DataRule.syncRuleByYear(this.fieldDrawer.template.id, this.otherYearDialog.year).then(res => {
if (res.code === 200) {
this.$message.success('规则同步成功')
this.otherYearDialog.show = false
this.queryFieldList()
}
}).finally(_ => this.otherYearDialog.loading = false)
}
}
},
// 模板下载
downloadTemplate(row) {
......@@ -1269,7 +1303,8 @@ export default {
// 打开规则新增框框
openRuleAddDialog() {
this.ruleDialog.data = {
type: '模板规则'
type: '模板规则',
remarks: '0'
}
this.ruleDialog.title = '新增规则'
this.ruleDialog.show = true
......@@ -1307,7 +1342,7 @@ export default {
} else {
return item
}
})
}).join('+')
}
},
// 删除模板规则
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment