马宇豪
2025-04-23 34ec919649adfefeecd0418284dd7b02e9ed49b8
src/views/specialCheck/components/sendWork.vue
@@ -8,9 +8,27 @@
        center
        @close="resetForm('workForm')"
    >
<!--        <el-upload-->
<!--            class="upload-demo"-->
<!--            action-->
<!--            :http-request="uploadFile"-->
<!--            :on-preview="handlePreview"-->
<!--            :on-remove="handleRemove"-->
<!--            :before-upload="beforeUpload"-->
<!--            :before-remove="beforeRemove"-->
<!--            multiple-->
<!--            :limit="1"-->
<!--            :on-exceed="handleExceed"-->
<!--            accept=".pdf, .doc, .docx"-->
<!--            :file-list="fileList">-->
<!--            <div style="display: flex;align-items: center">-->
<!--                <el-button type="primary" style="margin-right: 80px">检查内容上传</el-button>-->
<!--                <div slot="tip" class="el-upload__tip">只能上传doc/docx文件</div>-->
<!--            </div>-->
<!--        </el-upload>-->
        <el-form :model="workForm" :rules="rules" ref="workForm" label-width="80px">
            <el-form-item label="专项检查任务名称:" label-width="180px" prop="taskName">
                <el-input type="textarea" v-model="workForm.taskName"></el-input>
                <el-input v-model="workForm.taskName"></el-input>
            </el-form-item>
            <div class="form-part">
                <h3>省级检查指标</h3>
@@ -64,7 +82,7 @@
                </el-row>
            </div>
            <div class="form-part">
                <h3>市州级检查指标</h3>
                <h3>地(州、市)级检查指标</h3>
<!--                <p>批发企业:</p>-->
                <el-divider content-position="left">批发企业</el-divider>
                <el-row>
@@ -163,15 +181,16 @@
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
<!--          <el-button type="warning" @click="cancleSend" plain>取消</el-button>-->
          <el-button @click="resetForm('workForm')">重置</el-button>
          <el-button type="primary" @click="confirmSend('workForm')">确认下发</el-button>
          <el-button type="primary" v-stop-re-click @click="confirmSend('workForm')">确认下发</el-button>
        </span>
    </el-dialog>
</template>
<script>
    import {computePageCount} from "@/utils";
    import{sendCheckTask} from "@/api/specialCheck"
    import{sendCheckTask, uploadFile, delateFile} from "@/api/specialCheck"
    export default {
        name: "sendWork",
        data(){
@@ -216,28 +235,134 @@
        watch: {
        },
        methods:{
            //上传文件的事件
            // async uploadFile(item){
            //     const t = this
            //     const loading = this.$loading({
            //         lock: true,
            //         text: '正在上传文件...',
            //         spinner: 'el-icon-loading'
            //     });
            //     //上传文件的需要formdata类型;所以要转
            //     let FormDatas = new FormData()
            //     FormDatas.append('taskDescFile',item.file);
            //     const res = await uploadFile(FormDatas)
            //     if(res.data.code == '200'){
            //         loading.close();
            //         t.$message({
            //             type:'success',
            //             message: '上传成功'
            //         })
            //         t.fileList.push(item.file)
            //         console.log(t.fileList,'fileList')
            //         t.workForm.taskDescFileName = res.data.result
            //     }else{
            //         loading.close();
            //         t.$message({
            //             type:'warning',
            //             message:res.data.message
            //         })
            //     }
                // axios({
                //     method: 'post',
                //     url: 'http://192.168.0.29:8100/checkTask/upload/taskDescFile',
                //     headers:this.headers,
                //     timeout: 30000,
                //     data: FormDatas
                // }).then(res=>{
                //     if(res.data.id != '' || res.data.id != null){
                //         this.fileList.push(item.file);//成功过后手动将文件添加到展示列表里
                //         let i = this.fileList.indexOf(item.file)
                //         this.fileList[i].id = res.data.id;//id也添加进去,最后整个大表单提交的时候需要的
                //         if(this.fileList.length > 0){//如果上传了附件就把校验规则给干掉
                //             this.fileflag = false;
                //             this.$set(this.rules.url,0,'')
                //         }
                //         //this.handleSuccess();
                //     }
                // })
            // },
            //上传文件之前
            // beforeUpload(file){
                // const t = this
                // if (file.type != "" || file.type != null || file.type != undefined){
                //     //截取文件的后缀,判断文件类型
                //     console.log(t.fileType,file.name,'666')
                //     const FileExt = file.name.replace(/.+\./, "").toLowerCase();
                //     // //计算文件的大小
                //     // const isLt5M = file.size / 1024 / 1024 < 50; //这里做文件大小限制
                //     // //如果大于50M
                //     // if (!isLt5M) {
                //     //     this.$showMessage('上传文件大小不能超过 50MB!');
                //     //     return false;
                //     // }
                //     //如果文件类型不在允许上传的范围内
                //     if(t.fileType.indexOf(FileExt) !== -1){
                //         return true;
                //     }
                //     else {
                //         t.$message.error("上传文件格式不正确!");
                //         return false;
                //     }
                // }
            // },
            // async handleRemove(file, fileList) {
            //     const t = this
            //     const res = await delateFile({taskDescFileName: t.workForm.taskDescFileName})
            //     if(res.data.code == '200'){
            //         t.$message({
            //             type:'success',
            //             message: '删除成功'
            //         })
            //         t.fileList = []
            //     }else{
            //         t.$message({
            //             type:'warning',
            //             message:res.data.message
            //         })
            //     }
            // },
            // handlePreview(file) {
            //     console.log(file);
            // },
            // handleExceed(files, fileList) {
            //     this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
            // },
            // beforeRemove(file, fileList) {
            //     return this.$confirm(`确定移除 ${ file.name }?`);
            // },
            confirmSend(formName){
                const t = this
                console.log(t.workForm,'66666666666')
                t.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.$confirm('此操作将把任务下发给所有单位, 是否继续?', '提示', {
                        this.$confirm('确认将任务下发到所有单位,一经下发不可修改撤回,请谨慎核对!', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                            type: 'warning',
                            center: true,
                            cancelButtonClass: 'canBtn',
                            confirmButtonClass: 'sendBtn'
                        }).then(async () => {
                            const loading = this.$loading({
                                lock: true,
                                text: '正在下发...',
                                spinner: 'el-icon-loading'
                            });
                            let res = await sendCheckTask(t.workForm)
                            if(res.data.code === "200"){
                                loading.close();
                                t.$message({
                                    type:'success',
                                    message: '任务下发成功'
                                })
                            }else{
                                loading.close();
                                t.$message({
                                    type:'warning',
                                    message:res.data.message
                                })
                            }
                            // t.fileList = []
                            t.dialogVisible = false
                            t.$parent.getSpecialCheckTask();
                        }).catch(() => {
@@ -251,14 +376,35 @@
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            // cancleSend(){
            //    this.resetForm('workForm')
            //     this.dialogVisible = false
            // },
            async resetForm(formName) {
                const t = this
                // if(t.workForm.taskDescFileName !== null){
                //     const res = await delateFile({taskDescFileName: t.workForm.taskDescFileName})
                //     if(res.data.code == '200'){
                //         t.$message({
                //             type:'success',
                //             message: '已取消下发'
                //         })
                //     }else{
                //         t.$message({
                //             type:'warning',
                //             message:res.data.message
                //         })
                //     }
                // }
                t.$refs[formName].resetFields()
                // t.fileList = []
            }
        },
    }
</script>
<style lang="scss" scoped>
    .input-with-select .el-select {
        width: 120px;
    }
@@ -270,6 +416,7 @@
        background-color: #fafafa;
        color: #034EA2;
    }
    .form-part{
        background: #fafafa;
        padding: 10px 15px;
@@ -292,3 +439,15 @@
        }
    }
</style>
<style>
.canBtn{
    width: 30%;
    font-size: 16px;
}
.sendBtn{
    width: 30%;
    font-size: 16px;
    background-color: #ff5555 !important;
    border-color: rgba(0,0,0,0);
}
</style>