Browse Source

修改 查看

lfj 3 years ago
parent
commit
81a9e68c4c

+ 23 - 0
fjs-scenic-manager/src/main/java/com/fjs/scenic/controller/system/InputInfoController.java

@@ -81,6 +81,17 @@ public class InputInfoController {
         return ReturnResult.ok();
     }
 
+    @PostMapping("/edit")
+    @Transactional(rollbackFor = Exception.class)
+    public ReturnResult edit(@RequestBody List<InputInfoDto> inputInfoDtos) {
+        InputInfoDto inputInfoDto = inputInfoDtos.get(0);
+        inputInfoService.updateById(inputInfoDto);
+        if (inputInfoDto.getIncome() != null) {
+            inpIncomeService.updateBatchById(inputInfoDto.getIncome());
+        }
+        return ReturnResult.ok();
+    }
+
     @PostMapping("/page")
     public ReturnResult page(@RequestBody InputInfoPageParam param) {
         return ReturnResult.ok(inputInfoService
@@ -98,6 +109,7 @@ public class InputInfoController {
     @PostMapping("/del")
     @ResponseBody
     public ReturnResult del(int id) {
+        inpIncomeService.remove(new LambdaQueryWrapper<InpIncome>().eq(InpIncome::getInputInfoId, id));
         return ReturnResult.ok(inputInfoService.removeById(id));
     }
 
@@ -114,4 +126,15 @@ public class InputInfoController {
         return ReturnResult.ok(typeAuthorities.stream().map(TypeAuthority::getScenic).collect(Collectors.toList()));
     }
 
+    /**
+     * 获取 income
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/get")
+    public ReturnResult get(Integer id) {
+        return ReturnResult.ok(inpIncomeService.list(new LambdaQueryWrapper<InpIncome>().eq(InpIncome::getInputInfoId, id)));
+    }
+
 }

+ 113 - 93
fjs-scenic-manager/src/main/resources/templates/system/inputInfo.html

@@ -70,10 +70,10 @@
                         </el-table-column>
                         <el-table-column label="操作" min-width="300px">
                             <template slot-scope="scope">
-                                <el-button size="mini" type="primary" @click="authorityClick(scope.$index, scope.row)">
+                                <el-button size="mini" type="primary" @click="table1View(scope.$index, scope.row)">
                                     查看
                                 </el-button>
-                                <el-button size="mini" type="primary" @click="table1Edit(scope.$index, scope.row)">修改
+                                <el-button size="mini" type="primary" @click="table1View(scope.$index, scope.row,'edit')">修改
                                 </el-button>
                                 <el-button size="mini" type="danger" @click="table1Del(scope.$index, scope.row)">删除
                                 </el-button>
@@ -92,6 +92,7 @@
                             <span class="demonstration">数据日期</span>
                             <el-date-picker
                                 v-model="staticDate"
+                                :disabled="disableStaticDate"
                                 type="date"
                                 format="yyyy-MM-dd"
                                 value-format="yyyy-MM-dd"
@@ -101,7 +102,7 @@
                             </el-date-picker>
                         <el-collapse v-model="collapse">
                             <el-collapse-item title="大峡谷景区" name="0" v-if="addData[0].show">
-                                <el-form :model="addData[0]" status-icon :label-width="formLabelWidth" inline ref="form0">
+                                <el-form :model="addData[0]" status-icon :label-width="formLabelWidth" inline ref="form0" :disabled="disableForm">
                                     <template v-for="(item,i) in addData[0].income">
                                         <el-form-item :label="item.item" :prop="'income['+i+'].sum'" :rules="commonRule">
                                             <el-input-number v-model="item.sum" controls-position="right" :min="0"></el-input-number>
@@ -126,7 +127,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="水车坪景区" name="1" v-if="addData[1].show">
-                                <el-form :model="addData[1]" status-icon :label-width="formLabelWidth" inline ref="form1">
+                                <el-form :model="addData[1]" status-icon :label-width="formLabelWidth" inline ref="form1" :disabled="disableForm">
                                     <template v-for="(item,i) in addData[1].income">
                                         <el-form-item :label="item.item" :prop="'income['+i+'].sum'" :rules="commonRule">
                                             <el-input-number v-model="item.sum" controls-position="right" :min="0"></el-input-number>
@@ -151,7 +152,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="濯水景区" name="2" v-if="addData[2].show">
-                                <el-form :model="addData[2]" status-icon :label-width="formLabelWidth" inline ref="form2">
+                                <el-form :model="addData[2]" status-icon :label-width="formLabelWidth" inline ref="form2" :disabled="disableForm">
                                     <template v-for="(item,i) in addData[2].income">
                                         <el-form-item :label="item.item" :prop="'income['+i+'].sum'" :rules="commonRule">
                                             <el-input-number v-model="item.sum" controls-position="right" :min="0"></el-input-number>
@@ -176,7 +177,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="小南海" name="3"  v-if="addData[3].show">
-                                <el-form :model="addData[3]" status-icon :label-width="formLabelWidth" inline ref="form3">
+                                <el-form :model="addData[3]" status-icon :label-width="formLabelWidth" inline ref="form3" :disabled="disableForm">
                                     <el-form-item label="合计收入" prop="total" :rules="commonRule">
                                         <el-input-number 
                                         v-model="addData[3].total" 
@@ -195,7 +196,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="十三寨" name="4"  v-if="addData[4].show">
-                                <el-form :model="addData[4]" status-icon :label-width="formLabelWidth" inline ref="form4">
+                                <el-form :model="addData[4]" status-icon :label-width="formLabelWidth" inline ref="form4" :disabled="disableForm">
                                     <template v-for="(item,i) in addData[4].income">
                                         <el-form-item :label="item.item" :prop="'income['+i+'].sum'" :rules="commonRule">
                                             <el-input-number v-model="item.sum" controls-position="right" :min="0"></el-input-number>
@@ -220,7 +221,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="神龟峡景区" name="5"  v-if="addData[5].show">
-                                <el-form :model="addData[5]" status-icon :label-width="formLabelWidth" inline ref="form5">
+                                <el-form :model="addData[5]" status-icon :label-width="formLabelWidth" inline ref="form5" :disabled="disableForm">
                                     <template v-for="(item,i) in addData[5].income">
                                         <el-form-item :label="item.item" :prop="'income['+i+'].sum'" :rules="commonRule">
                                             <el-input-number v-model="item.sum" controls-position="right" :min="0"></el-input-number>
@@ -245,7 +246,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="官村" name="6"  v-if="addData[6].show">
-                                <el-form :model="addData[6]" status-icon :label-width="formLabelWidth" inline ref="form6">
+                                <el-form :model="addData[6]" status-icon :label-width="formLabelWidth" inline ref="form6" :disabled="disableForm">
                                     <el-form-item label="合计收入" prop="total" :rules="commonRule">
                                         <el-input-number 
                                         v-model="addData[6].total" 
@@ -264,7 +265,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="爱莉丝" name="7"  v-if="addData[7].show">
-                                <el-form :model="addData[7]" status-icon :label-width="formLabelWidth" inline ref="form7">
+                                <el-form :model="addData[7]" status-icon :label-width="formLabelWidth" inline ref="form7" :disabled="disableForm">
                                     <el-form-item label="合计收入" prop="total" :rules="commonRule">
                                         <el-input-number 
                                         v-model="addData[7].total" 
@@ -283,7 +284,7 @@
                                 </el-form>
                             </el-collapse-item>
                             <el-collapse-item title="阿蓬江旅行社公司" name="8" v-if="addData[8].show">
-                                <el-form :model="addData[8]" status-icon :label-width="formLabelWidth" inline ref="form8">
+                                <el-form :model="addData[8]" status-icon :label-width="formLabelWidth" inline ref="form8" :disabled="disableForm">
                                     <template v-for="(item,i) in addData[8].income">
                                         <el-form-item :label="item.item" :prop="'income['+i+'].sum'" :rules="commonRule">
                                             <el-input-number v-model="item.sum" controls-position="right" :min="0"></el-input-number>
@@ -309,7 +310,7 @@
                             </el-collapse-item>
                         </el-collapse>
                         <div slot="footer" class="dialog-footer">
-                            <el-button type="primary" @click="dialog1Sub('dialog1')">提 交</el-button>
+                            <el-button type="primary" @click="dialog1Sub('dialog1')" :disabled="disableForm">提 交</el-button>
                             <el-button @click="dialog1Visible = false">取 消</el-button>
                         </div>
                     </el-dialog>
@@ -352,11 +353,88 @@
                 label: '阿蓬江旅行社公司',
                 children: [{ value: 8, label: '阿蓬江旅行社公司' }]
             }]
+        const FULL_ADD_DATA = [
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[0].label,
+                    scenic: COMPANY_SCENIC[0].children[0].label,
+                    income: initIncomeFunc(['门票 散客人次', '门票 团队人次', '门票收入', '中转车收入', '停车费收入', '玻璃桥索道收入'])
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[0].label,
+                    scenic: COMPANY_SCENIC[0].children[1].label,
+                    income: initIncomeFunc(['骑马收入', '露营收入'])
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[0].label,
+                    scenic: COMPANY_SCENIC[0].children[2].label,
+                    income: initIncomeFunc(['暗河门票 散客人次', '暗河门票 团队人次', '门票收入', '花田收入', '钟楼收入',
+                        '芭茅岛酒店收入', '蒲花河酒店收入', '水乐园收入', '特产馆收入', '暗河购物中心收入',
+                        '观光车收入', '竹筏收入', '快艇收入', '水上自行车收入'])
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[0].label,
+                    scenic: COMPANY_SCENIC[0].children[3].label
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[0].label,
+                    scenic: COMPANY_SCENIC[0].children[4].label,
+                    income: initIncomeFunc(['门票 散客人次', '门票 团队人次', '门票收入'])
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[1].label,
+                    scenic: COMPANY_SCENIC[1].children[0].label,
+                    income: initIncomeFunc(['船票 散客人次', '船票 团队人次', '船票收入'])
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[2].label,
+                    scenic: COMPANY_SCENIC[2].children[0].label
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[2].label,
+                    scenic: COMPANY_SCENIC[2].children[1].label
+                },
+                {
+                    total:0,
+                    show:false,
+                    personTimes:0,
+                    company: COMPANY_SCENIC[3].label,
+                    scenic: COMPANY_SCENIC[3].children[0].label,
+                    income: initIncomeFunc(['组团收入', '地接收入', '研学收入','导服收入','组团人次','地接人次','研学人次','收入合计','合计人次'])
+                }
+            ]
+        const copy = obj => JSON.parse(JSON.stringify(obj))
+
 
         var option = {
             mixins: [dyMixin],
             data() {
                 return {
+                    disableStaticDate:false,
+                    disableForm: false,
                     staticDate:new Date().toJSON().slice(0,10),
                     formLabelWidth:'200px',
                     collapse: ['0', '1', '2', '3', '4', '5', '6', '7', '8'],
@@ -365,70 +443,7 @@
                     con: { dataTime: undefined, companyScenic: undefined, currentPage: 1, pageSize: 10, total: 0, createTime: undefined, },//查询条件
                     tableData: [],
                     dialog1Visible: false,//对话框隐藏
-                    addData: [
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[0].label,
-                            scenic: COMPANY_SCENIC[0].children[0].label,
-                            income: initIncomeFunc(['门票 散客人次', '门票 团队人次', '门票收入', '中转车收入', '停车费收入', '玻璃桥索道收入'])
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[0].label,
-                            scenic: COMPANY_SCENIC[0].children[1].label,
-                            income: initIncomeFunc(['骑马收入', '露营收入'])
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[0].label,
-                            scenic: COMPANY_SCENIC[0].children[2].label,
-                            income: initIncomeFunc(['暗河门票 散客人次', '暗河门票 团队人次', '门票收入', '花田收入', '钟楼收入',
-                                '芭茅岛酒店收入', '蒲花河酒店收入', '水乐园收入', '特产馆收入', '暗河购物中心收入',
-                                '观光车收入', '竹筏收入', '快艇收入', '水上自行车收入'])
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[0].label,
-                            scenic: COMPANY_SCENIC[0].children[3].label
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[0].label,
-                            scenic: COMPANY_SCENIC[0].children[4].label,
-                            income: initIncomeFunc(['门票 散客人次', '门票 团队人次', '门票收入'])
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[1].label,
-                            scenic: COMPANY_SCENIC[1].children[0].label,
-                            income: initIncomeFunc(['船票 散客人次', '船票 团队人次', '船票收入'])
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[2].label,
-                            scenic: COMPANY_SCENIC[2].children[0].label
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[2].label,
-                            scenic: COMPANY_SCENIC[2].children[1].label
-                        },
-                        {
-                            total:0,
-                            personTimes:0,
-                            company: COMPANY_SCENIC[3].label,
-                            scenic: COMPANY_SCENIC[3].children[0].label,
-                            income: initIncomeFunc(['组团收入', '地接收入', '研学收入','导服收入','组团人次','地接人次','研学人次','收入合计','合计人次'])
-                        }
-                    ],//新增数据模板
+                    addData:copy(FULL_ADD_DATA),
                     editData: {},//编辑数据
                     typeAuthority: Object.assign(TYPE_AUTHORITY),//角色数据
                     roleIds: [],
@@ -448,8 +463,11 @@
                     let _this = this;
                     $.dyAjax('/inputInfo/getTypeAuthority', {}, function (data) {
                         _this.dialog1Visible = true
+                        _this.addData = copy(FULL_ADD_DATA)
                         _this.addData.forEach((item,i) => item.show = data.includes(i) )
                         _this.collapse = Array.from(data, item => item+'')
+                        _this.disableStaticDate = false
+                        _this.disableForm = false
                     });
                 },
                 countVal(scenic,form,to){
@@ -504,16 +522,14 @@
                             promises.push(this.$refs['form'+i].validate())
                         }
                     })
-
                     Promise.allSettled(promises).then((results) => {
                        const fail = results.findIndex(result => result.status==='rejected' )>-1
                         if (!fail) {
                             const datas = Object.assign([],_this.addData)
-                            console.log(datas);
                             datas.forEach(el => el.staticDate = this.staticDate)
                             const datasFilter = datas.filter(el => el.show)
-                            console.log(datasFilter);
-                            $.dyjAjax('/inputInfo/add', datasFilter, function (data) {
+                            const method = datasFilter[0].id?'/inputInfo/edit':'/inputInfo/add'
+                            $.dyjAjax(method, datasFilter, function (data) {
                                 _this.loadTable1(function () {
                                     _this.$message({
                                         type: 'success',
@@ -559,20 +575,24 @@
                     }).catch(() => {
                     });
                 },
-                //分配权限
-                authorityClick: function (index, row) {
+                // 查看
+                table1View: function (index, row,type = 'view') {
+                    const {personTimes,scenic,staticDate,total,id} = row
                     var _this = this;
-                    $.dyAjax('/inputInfo/getTypeAuthority/' + row.id, undefined, function (data) {
-                        if (data.length > 0) {
-                            let companyScenic = data.reduce((acc, cur) => {
-                                acc.push([cur.company, cur.scenic])
-                                return acc
-                            }, [])
-                            _this.typeAuthority = { authority: data[0].authority ? 1 : 0, companyScenic, manager: row.id }
-                        } else {
-                            _this.typeAuthority = Object.assign(TYPE_AUTHORITY, { manager: row.id })
-                        }
-                        _this.dialog3Visible = true;
+                    $.dyAjax('/inputInfo/get', {id}, function (data) {
+                        _this.addData = copy(FULL_ADD_DATA)
+                        _this.addData.forEach(item => {
+                            if(item.scenic === scenic){
+                                item.show = true
+                                item.income = data
+                                Object.assign(item,{personTimes,scenic,staticDate,total,id})
+                            }else{
+                                item.show = false
+                            }
+                        })
+                        _this.dialog1Visible = true
+                        _this.disableStaticDate = true
+                        _this.disableForm = type === 'view'
                     });
                 },
             },