| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <template>
- <el-dialog
- :title="title"
- :visible="visible"
- width="320px"
- :append-to-body="true"
- :close-on-click-modal="false"
- @close="dialogClose"
- >
- <el-select v-model="user[bindKey]" :placeholder="placeholder" :multiple="isMultiple">
- <el-option v-for="item in memberList" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- <div v-if="type === typeList[0].type" class="end-date">
- <span>交稿日期:</span>
- <el-date-picker v-model="editEndDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" />
- </div>
- <div slot="footer">
- <el-button @click="dialogClose">取消</el-button>
- <el-button type="primary" @click="addChapterNode">确定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- export default {
- name: 'SetUser',
- props: {
- visible: {
- type: Boolean,
- required: true,
- },
- id: {
- type: String,
- default: '',
- },
- memberList: {
- type: Array,
- required: true,
- },
- type: {
- type: String,
- default: 'producer',
- },
- list: {
- type: Array,
- default: () => [],
- },
- },
- data() {
- return {
- user: {
- id_list: [],
- id: '',
- },
- typeList: [
- { type: 'producer', label: '设置制作人', placeholder: '请选择制作人', bindKey: 'id_list', isMultiple: true },
- { type: 'auditor', label: '设置审校人', placeholder: '请选择审校人', bindKey: 'id_list', isMultiple: true },
- { type: 'mainAuditor', label: '设置主审校人', placeholder: '请选择主审校人', bindKey: 'id', isMultiple: false },
- ],
- editEndDate: '',
- };
- },
- computed: {
- title() {
- return this.typeList.find((item) => item.type === this.type).label;
- },
- placeholder() {
- return this.typeList.find((item) => item.type === this.type).placeholder;
- },
- isMultiple() {
- return this.typeList.find((item) => item.type === this.type).isMultiple;
- },
- bindKey() {
- return this.typeList.find((item) => item.type === this.type).bindKey;
- },
- },
- watch: {
- list: {
- handler(val) {
- if (this.type !== 'producer') return;
- if (val.length === 0) {
- this.user = {
- id_list: [],
- id: '',
- };
- return;
- }
- if (this.isMultiple) {
- this.user.id_list = val.map(({ id }) => id);
- } else {
- this.user.id = val[0]?.id || '';
- }
- },
- deep: true,
- },
- },
- methods: {
- dialogClose() {
- this.$emit('update:visible', false);
- this.user = {
- id_list: [],
- id: '',
- };
- },
- addChapterNode() {
- if (this.type === this.typeList[0].type) {
- if (this.editEndDate.length === 0) {
- this.$message.error('请选择交稿日期');
- return;
- }
- this.$emit('chapterSetProducer', {
- node_id: this.id,
- producer_id_list: this.user.id_list,
- edit_end_date: this.editEndDate,
- });
- }
- if (this.type === this.typeList[1].type) {
- this.$emit('SetAuditor', { flow_node_id: this.id, user_id_list: this.user.id_list });
- }
- if (this.type === this.typeList[2].type) {
- this.$emit('SetMainAuditor', { flow_node_id: this.id, user_id: this.user.id });
- }
- this.dialogClose();
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .el-select {
- width: 100%;
- }
- .el-dialog {
- .end-date {
- display: flex;
- align-items: center;
- margin-top: 16px;
- span {
- width: 80px;
- }
- .el-date-picker {
- flex: 1;
- }
- }
- }
- </style>
|