add 设备工段绑定,设备分组
This commit is contained in:
@@ -53,7 +53,12 @@
|
||||
:action="col.url"
|
||||
:on-success="handleUploadSuccess"
|
||||
v-bind="col.bind">
|
||||
<el-button size="small" type="primary" :disabled="col.bind?.disabled || false">点击上传</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
:disabled="col.bind?.disabled || false">
|
||||
点击上传
|
||||
</el-button>
|
||||
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
|
||||
{{ col.uploadTips || '只能上传jpg/png文件,大小不超过2MB' }}
|
||||
</div>
|
||||
@@ -157,7 +162,7 @@ export default {
|
||||
return response.data;
|
||||
},
|
||||
async handleOptions(trigger = 'monuted') {
|
||||
// console.log("[dialogForm:handleOptions]")
|
||||
console.log("[dialogForm:handleOptions]")
|
||||
const promiseList = [];
|
||||
this.rows.forEach((cols) => {
|
||||
cols.forEach((opt) => {
|
||||
@@ -169,6 +174,32 @@ export default {
|
||||
if (opt.options) {
|
||||
this.$set(this.optionListOf, opt.prop, opt.options);
|
||||
} else if (opt.url) {
|
||||
// 如果有 depends,则暂时先不获取,注册一个watcher
|
||||
if (opt.depends) {
|
||||
console.log("[handleOptions] setting watch")
|
||||
this.$watch(
|
||||
() => this.form[opt.depends],
|
||||
(id) => {
|
||||
console.log(opt.depends, 'changed')
|
||||
// 清空原有选项
|
||||
this.form[opt.prop] = null;
|
||||
// 获取新的选项
|
||||
this.$axios({
|
||||
url: `${opt.url}?id=${id}`,
|
||||
}).then((res) => {
|
||||
this.$set(
|
||||
this.optionListOf,
|
||||
opt.prop,
|
||||
res.data.map((item) => ({
|
||||
label: item[opt.labelKey ?? 'name'],
|
||||
value: item[opt.valueKey ?? 'id'],
|
||||
}))
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
// 如果是下拉框,或者新增模式下的输入框,才去请求
|
||||
if (opt.select || (opt.input && !this.form?.id)) {
|
||||
promiseList.push(async () => {
|
||||
@@ -216,10 +247,16 @@ export default {
|
||||
if (!promiseList.length) this.formLoading = false;
|
||||
},
|
||||
// 上传成功的特殊处理
|
||||
beforeUpload(){},
|
||||
beforeUpload() {},
|
||||
// 上传前的验证规则可通过 bind 属性传入
|
||||
handleUploadSuccess(response, file, fileList) {
|
||||
console.log('[dialogForm:handleUploadSuccess]', response, file, fileList, this.form);
|
||||
console.log(
|
||||
'[dialogForm:handleUploadSuccess]',
|
||||
response,
|
||||
file,
|
||||
fileList,
|
||||
this.form
|
||||
);
|
||||
// 保存原始文件名
|
||||
if ('fileNames' in this.form) this.form.fileNames.push(file.name);
|
||||
// 保存完整地址
|
||||
|
||||
Reference in New Issue
Block a user