fzq #31

Closed
fanzhiqin wants to merge 215 commits from fzq into test
2 changed files with 64 additions and 20 deletions
Showing only changes of commit cfec6ff3f5 - Show all commits

View File

@ -15,14 +15,22 @@
v-if="getType(n, c) === 'input'"
:placeholder="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].placeholder || '...'"
v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"
clearable
/>
<el-radio v-if="getType(n, c) === 'radio'"></el-radio>
<el-checkbox v-if="getType(n, c) === 'check'"></el-checkbox>
<el-select v-if="getType(n, c) === 'select'" :placeholder="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].placeholder || ''"></el-select>
<el-switch v-if="getType(n, c) === 'switch'"></el-switch>
<el-cascader v-if="getType(n, c) === 'tree'"></el-cascader>
<el-time-select v-if="getType(n, c) === 'time'"></el-time-select>
<el-date-picker v-if="getType(n, c) === 'date'"></el-date-picker>
<el-radio v-if="getType(n, c) === 'radio'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-radio>
<el-checkbox v-if="getType(n, c) === 'check'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-checkbox>
<el-select
v-if="getType(n, c) === 'select'"
:placeholder="configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].placeholder || ''"
v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"
clearable
>
<el-option v-for="opt in configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].options" :key="opt.label" :value="opt.value" />
</el-select>
<el-switch v-if="getType(n, c) === 'switch'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-switch>
<el-cascader v-if="getType(n, c) === 'tree'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-cascader>
<el-time-select v-if="getType(n, c) === 'time'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-time-select>
<el-date-picker v-if="getType(n, c) === 'date'" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
@ -145,10 +153,10 @@ export default {
/** 自动请求并填充 */
this.$http({
url: this.$http.adornUrl(item.api),
methods: 'get'
method: 'POST' //
}).then(({ data: res }) => {
if (data & (data.code === 0)) {
this.dataFrom[item.name] = res.data // <===
if (res && res.code === 0) {
this.dataForm[item.name] = res.data // <===
}
})
} // end if (item.api)
@ -241,15 +249,51 @@ export default {
this.visible = true
},
handleClick(btn) {
switch (btn.name) {
case 'save':
break
case 'update':
break
case 'reset':
break
// add more..
}
this.$refs['dataForm'].validate(valid => {
if (valid) {
/** 提取url */
const urls = {}
this.configs.operations.map(item => {
urls[item.name] = item.url
})
/** 操作 */
switch (btn.name) {
case 'save':
case 'update':
this.$http({
url: this.$http.adornUrl(urls[btn.name]),
method: btn.name === 'save' ? 'POST' : 'PUT',
data: this.dataForm
}).then(({ data: res }) => {
if (data && data.code === 0) {
this.$message({
message: btn.name === 'save' ? '添加成功!' : '更新成功!',
type: 'success',
duration: 1500,
onClose() {
this.$emit('refreshDataList')
this.visible = false
}
})
}
})
return
case 'reset':
for (const key of Object.keys(this.dataForm)) {
if (typeof this.dataForm[key] === 'string') {
this.dataForm[key] = ''
} else if (this.dataForm[key] instanceof Array) {
this.dataForm[key].splice(0)
} else {
this.dataForm[key] = null
}
}
console.log('after reset: ', JSON.stringify(this.dataForm))
break
// add more..
}
}
})
},
handleClose() {
if (this.isAdd || this.isUpdated) this.$emit('refreshDataList')

View File

@ -100,7 +100,7 @@ const addOrUpdateConfigs = {
'name',
{
name: 'code',
api: 'xx/code'
api: '/monitoring/product/getCode'
},
{
name: 'processTime',