|
|
@@ -29,7 +29,19 @@
|
|
|
<el-switch v-model="formData.limited"></el-switch>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="collectionIds" label="藏品" v-if="formData.limited">
|
|
|
- <el-input v-model="formData.collectionIds"></el-input>
|
|
|
+ <el-table :data="collections">
|
|
|
+ <el-table-column type="index" label="#"></el-table-column>
|
|
|
+ <el-table-column prop="id" label="ID"></el-table-column>
|
|
|
+ <el-table-column prop="name" label="名称"></el-table-column>
|
|
|
+ <el-table-column width="80" align="center">
|
|
|
+ <template v-slot="{ row, $index }">
|
|
|
+ <el-button type="danger" plain @click="delCollection($index)" size="mini"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <el-button @click="addCollection" size="mini">添加</el-button>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="expiration" label="到期时间">
|
|
|
<el-date-picker
|
|
|
@@ -49,6 +61,27 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
+ <el-dialog title="添加藏品" :visible.sync="showCollectionDialog" width="500px">
|
|
|
+ <el-form :model="{ collectionId }" ref="collectionForm" inline>
|
|
|
+ <el-form-item prop="collectionId" :rules="{ required: true, message: '请选择藏品' }">
|
|
|
+ <el-select v-model="collectionId" filterable :filter-method="filterCollection">
|
|
|
+ <el-option
|
|
|
+ v-for="item in collectionOptions"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ :key="item.id"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{ item.name }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">#{{ item.id }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="showCollectionDialog = false">取消</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="saveCollection">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -67,6 +100,19 @@ export default {
|
|
|
this.$message.error(e.error);
|
|
|
});
|
|
|
}
|
|
|
+ this.$http
|
|
|
+ .post(
|
|
|
+ '/collection/all',
|
|
|
+ {
|
|
|
+ size: 10000,
|
|
|
+ sort: 'sort,desc;createdAt,desc',
|
|
|
+ query: { del: false, source: 'OFFICIAL' }
|
|
|
+ },
|
|
|
+ { body: 'json' }
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ this.collectionOptions = res.content;
|
|
|
+ });
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -117,7 +163,10 @@ export default {
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
- collections: []
|
|
|
+ collectionOptions: [],
|
|
|
+ collections: [],
|
|
|
+ showCollectionDialog: false,
|
|
|
+ collectionId: null
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -162,6 +211,35 @@ export default {
|
|
|
this.$message.error((e || {}).error || '删除失败');
|
|
|
}
|
|
|
});
|
|
|
+ },
|
|
|
+ addCollection() {
|
|
|
+ this.collectionId = null;
|
|
|
+ this.showCollectionDialog = true;
|
|
|
+ if (this.$refs.collectionForm) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.collectionForm.clearValidate();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ delCollection(index) {
|
|
|
+ this.collections.splice(index, 1);
|
|
|
+ },
|
|
|
+ saveCollection() {
|
|
|
+ this.$refs.collectionForm
|
|
|
+ .validate()
|
|
|
+ .then(() => {
|
|
|
+ if (!this.collections.find(i => i.id === this.collectionId)) {
|
|
|
+ this.collections.push(this.collectionOptions.find(i => i.id === this.collectionId));
|
|
|
+ this.showCollectionDialog = false;
|
|
|
+ } else {
|
|
|
+ this.$message.error('请勿重复添加');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ filterCollection(val) {
|
|
|
+ console.log(val);
|
|
|
+ return this.collectionOptions.filter(i => i.name.includes(val) || i.id == val);
|
|
|
}
|
|
|
}
|
|
|
};
|