| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <!-- 用户编辑弹窗 -->
- <template>
- <ele-modal
- width="960px"
- :visible="visible"
- :append-to-body="true"
- :close-on-click-modal="false"
- custom-class="ele-dialog-form"
- :title="isView ? '查看资质' : isUpdate ? '修改资质' : '添加资质'"
- @update:visible="updateVisible"
- :maxable="true"
- >
- <header-title title="基本信息"></header-title>
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-row>
- <el-col :span="10">
- <el-form-item label="资质类型:" prop="certificationType">
- <el-select
- style="width: 100%"
- :disabled="isView"
- v-model="form.certificationType"
- @change="changeCertificationType"
- filterable
- >
- <el-option
- v-for="item in qualificationOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="编码:" prop="code">
- <el-input
- :disabled="isView"
- v-model="form.code"
- clearable
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="10">
- <el-form-item label="类型:" prop="type">
- <el-select
- style="width: 100%"
- :disabled="isView"
- v-model="form.type"
- filterable
- >
- <el-option
- v-for="item in typeList"
- :key="item.dictCode"
- :label="item.dictValue"
- :value="item.dictCode"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="10">
- <el-form-item label="等级:" prop="level">
- <el-select
- style="width: 100%"
- :disabled="isView"
- v-model="form.level"
- filterable
- >
- <el-option
- :label="item.label"
- :value="item.value"
- v-for="(item, index) in levelOptions"
- :key="index"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="20">
- <el-form-item label="名称:" prop="name">
- <el-input
- :disabled="isView"
- v-model="form.name"
- readonly
- clearable
- @click.native="handleClick"
- placeholder="请选择"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="20">
- <el-form-item label="附件:" prop="accessory">
- <fileUpload
- v-if="!isView"
- v-model="filedList"
- :show-file-list="false"
- module="main"
- @input="uploadedSuccess($event, form)"
- :limit="1"
- />
- <div v-if="form.accessory?.storePath">
- <span>{{ form.accessory.name }}</span>
- <el-button
- style="margin-left: 10px"
- size="mini"
- type="primary"
- @click="downloadFile(form.accessory.storePath, form)"
- >下载</el-button
- >
- </div>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="20">
- <el-form-item label="有效时间:" prop="date">
- <el-date-picker
- :disabled="isView"
- v-model="form.date"
- type="daterange"
- value-format="yyyy-MM-dd HH:mm:ss"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <vendorDialog
- ref="vendorDialogRef"
- @success="confirmSelection"
- ></vendorDialog>
- <staffSelection
- ref="staffSelection"
- @confirm="confirmSelection"
- ></staffSelection>
- <clientDialog
- ref="clientSelection"
- @success="confirmSelection"
- ></clientDialog>
- <template v-slot:footer>
- <el-button @click="updateVisible(false)">取消</el-button>
- <el-button v-if="isView" type="primary" @click="updateVisible(false)">
- 确定
- </el-button>
- <el-button v-else type="primary" :loading="loading" @click="save">
- 保存
- </el-button>
- </template>
- </ele-modal>
- </template>
- <script>
- import clientDialog from './clientDialog.vue';
- import vendorDialog from './vendorDialog.vue';
- import staffSelection from './staffSelection.vue';
- import fileUpload from '@/components/upload/fileUpload';
- import { getFile } from '@/api/system/file';
- import {
- saveProfessionCertification,
- getProfessionCertificationById,
- updateProfessionCertificationById
- } from '@/api/factoryModel';
- export default {
- components: {
- fileUpload,
- vendorDialog,
- staffSelection,
- clientDialog
- },
- props: {
- // 弹窗是否打开
- visible: Boolean,
- // 修改回显的数据
- data: Object,
- isView: Boolean,
- controlList: Array,
- typeList: Array
- },
- data() {
- const defaultForm = function () {
- return {
- id: '',
- certificationType: '',
- code: '',
- personnelIds: '',
- level: '',
- name: '',
- type: '',
- status: 0,
- accessory: {},
- date: '小时'
- };
- };
- return {
- qualificationOptions: [
- {
- label: '客户资质',
- value: '1'
- },
- {
- label: '供应商资质',
- value: '2'
- },
- {
- label: '个人资质',
- value: '3'
- }
- ],
- filedList: [],
- defaultForm,
- // 表单数据
- form: defaultForm(),
- moneyOptions: [
- {
- label: '元',
- value: '元'
- }
- ],
- timeOptions: [
- {
- label: '小时',
- value: '小时'
- },
- {
- label: '天',
- value: '天'
- },
- {
- label: '月',
- value: '月'
- }
- ],
- levelOptions: [
- {
- label: '初级',
- value: '1'
- },
- {
- label: '中级',
- value: '2'
- },
- {
- label: '高级',
- value: '3'
- }
- ],
- // 表单验证规则
- rules: {
- name: [{ required: true, message: '请输入名称', trigger: 'change' }],
- code: [{ required: true, trigger: 'blur', message: '请输入编码' }],
- date: [{ required: true, message: '请选择资质', trigger: 'change' }],
- type: [{ required: true, message: '请选择类型', trigger: 'change' }]
- },
- // 提交状态
- loading: false,
- // 是否是修改
- isUpdate: false,
- chooseItem: null
- };
- },
- methods: {
- changeCertificationType(value) {
- this.form.certificationType = value;
- this.form.name = '';
- this.form.personnelIds = '';
- },
- handleClick() {
- switch (this.form.certificationType) {
- case '1':
- this.$refs.clientSelection.open();
- break;
- case '2':
- this.$refs.vendorDialogRef.open();
- break;
- case '3':
- this.$refs.staffSelection.open([]);
- break;
- }
- },
- confirmSelection(data) {
- console.log(data);
- this.form.personnelIds = data.map((item) => item.id).join(',');
- this.form.name = data.map((item) => item.name).join(',');
- this.$forceUpdate();
- },
- downloadFile(url, form) {
- console.log(form);
- getFile({ objectName: url }, '附件');
- },
- uploadedSuccess(data, row) {
- console.log(data, row);
- row.accessory.storePath = data[0].storePath;
- row.accessory.name = data[0].name;
- this.filedList = [];
- },
- /* 保存编辑 */
- save() {
- this.$refs.form.validate((valid) => {
- if (!valid) {
- return false;
- }
- console.log(this.form);
- if (!this.isUpdate) {
- delete this.form.id;
- }
- this.form.startTime = this.form.date[0];
- this.form.endTime = this.form.date[1];
- this.loading = true;
- let apiStr = null;
- if (this.isUpdate) {
- apiStr = updateProfessionCertificationById;
- } else {
- apiStr = saveProfessionCertification;
- }
- apiStr(this.form)
- .then((msg) => {
- this.loading = false;
- this.$message.success((this.isUpdate ? '修改' : '新建') + '成功');
- this.updateVisible(false);
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- // this.$message.error(e.message);
- });
- });
- },
- /* 更新visible */
- updateVisible(value) {
- this.form = { ...this.defaultForm() };
- this.$emit('update:visible', value);
- }
- },
- watch: {
- async visible(visible) {
- if (visible) {
- if (this.data) {
- const res = await getProfessionCertificationById(this.data.id);
- console.log(res);
- this.$util.assignObject(this.form, {
- ...res
- });
- this.form.date = [res.startTime, res.endTime];
- this.isUpdate = true;
- console.log(this.form);
- } else {
- this.filedList = [];
- this.form = { ...this.defaultForm() };
- this.isUpdate = false;
- }
- } else {
- this.$refs.form.clearValidate();
- this.form = { ...this.defaultForm() };
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .hourCostStyle {
- display: flex;
- > div {
- margin-right: 10px;
- }
- > div:last-child {
- margin-right: 0;
- }
- }
- </style>
|