赞
踩
需求:
现在区政府里需要调查各个乡镇的农户信息和农药使用情况。
但由于信息量太大,所以把它细分到各个村,各个组里去填写这两个表的填写情况。
现在我们以村为单位,划分调查任务。
(后期刁钻的细节是:设置用户权限,比如县级能分配任务,乡镇级别的可以填报任务)
x.vue
- <template>
- <div class="mod-work">
- <el-form :inline="true :model="searchForm">
- <el-form-item>
- <el-input v-model="searchForm.name"
- placeholder="填报单位"
- clearable>
- </el-input>
- </el-form-item>
- <el-form-item>
- <button >查询</button>
- <button
- v-if="isAuth('pesticide:crop:save')"
- type="primary"
- @click="addOrUpdateHandle()"
- >新增</button>
- <button
- v-if="isAuth('pesticide:crop:delete')"
- type="danger"
- @click="deleteHandle()"
- :disabled="dataListSelections.length <= 0"
- >批量删除</button>
- </el-form-item>
- <el-form>
- <el-table
- :data="dataList"
- @selection-change="selectionChangeHandle"
- border
- style="width: 100%">
- <el-table-column
- type="selection"
- header-align="center"
- align="center"
- width="50">
- </el-table-column>
- <el-table-column
- prop=""
- header-align="center"
- align="left"
- width="80"
- label="ID"
- >
- </el-table-column>
- <el-table-column
- prop=""
- header-align="center"
- align="left"
- treeKey="menuId"
- width="150"
- label="任务名">
- </el-table-column>
- <el-table-column prop=""
- header-align="center"
- align="left"
- width="150"
- label="开始时间">
- </el-table-column>
- <el-table-column prop=""
- header-align="center"
- align="left"
- width="150"
- label="截止时间">
- </el-table-column>
- <el-table-column
- prop=""
- header-align="center"
- align="left"
- width="150"
- label="截止时间">
- </el-table-column>
- <el-table-column
- fixed="right"
- header-align="center"
- align="center"
- width="150"
- label="操作"
- >
- <template slot-scope="scope">
- <el-button
- v-if="isAuth('')"
- type="text"
- size="small"
- @click="addOrUpdateHandle(scope.row.)"
- >修改
- </el-button>
- <el-button
- v-if="isAuth('sys:menu:delete')"
- type="text"
- size="small"
- @click="deleteHandle(scope.row.)"
- >
- 删除
- </el-button>
- </template>
- </el-table-column>
- <el-table-column
- prop="parentName"
- header-align="center"
- align="center"
- width="120"
- label="填写状态">
- </el-table-column>
- </el-table>
- <!-- 弹窗, 新增 / 修改 -->
- <add-or-update
- v-if="addOrUpdateVisible"
- ref="addOrUpdate"
- @refreshDataList="getDataList"
- ></add-or-update>
- </div>
- </template>
-
- <script>
- import TableTreeColumn from '@/components/table-tree-column'
- import AddOrUpdate from './list-add-or-update'
- export default{
- data(){
- return{
- searchForm: {},
- dataList: [],
- addOrUpdateVisible:false
- }
- },
- components:{
- TableTreeColumn,
- AddOrUpdate
- },
- activated(){
- this.getDateList()
- },
- methods:{
- // 获取数据列表
- getDataList() {
- this.$http({
- url: '',
- method: 'get'
- }).then(({ data }) => {
- this.dataList = this.treeDataTranslate(data.menuList, '', 'parentId', 'childrens')
- })
- },
- // 新增 / 修改
- addOrUpdateHandle(id) {
- this.addOrUpdateVisible = true
- this.$nextTick(() => {
- this.$refs.addOrUpdate.init(id)
- })
- },
-
- // 删除
- deleteHandle(id) {
- let ids = id ? [id] : this.dataListSelections.map(item => {
- return item.id
- })
- this.$confirm('确定对所选项进行[删除]操作?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: '',
- method: 'post',
- data: ids
- }).then(({ data }) => {
- if (data && data.code === 0) {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500
- })
- this.getDataList()
- }
- })
- }).catch(() => {
- })
- }
- }
- }
- </script>
x.add-or-update.com
- <template>
- <el-dialog
- :title="!dataForm.id ? '新增' : '修改'"
- :close-on-click-modal="false"
- :visible.sync="visible">
- <el-form
- :model="dataForm"
- :rules="dataRule"
- ref="dataForm"
- @keyup.enter.native="dataFormSubmit()"
- label-width="80px">
- <el-form-item label="类型" prop="type">
- <el-radio-group v-model="dataForm.type">
- <el-radio v-for="(type, index) in dataForm.typeList" :label="index" :key="index">{{ type }}</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item :label="dataForm.typeList[dataForm.type] + '名称'" prop="name">
- <el-input v-model="dataForm.name" :placeholder="dataForm.typeList[dataForm.type] + '名称'"></el-input>
- </el-form-item>
- <el-form-item label="上级菜单" prop="parentName">
- <el-dialog
- width="30%"
- append-to-body
- title="选择上级菜单"
- :visible.sync="visiblePopover">
- <el-tree
- :data="menuList"
- :props="menuListTreeProps"
- node-key="menuId"
- @current-change="menuListTreeCurrentChangeHandle"
- default-expand-all
- :expand-on-click-node="false">
- </el-tree>
- </el-dialog>
- <el-button @click="visiblePopover = true">{{dataForm.parentName||'点击选择上级菜单'}}</el-button>
- </el-form-item>
- <el-form-item v-if="dataForm.type === 0 || 1"
- label="年份"
- prop=""
- :rules="[{ required: true, message: '请选择年份', trigger: 'blur' }]"
- >
- <!-- <el-input v-model="dataForm.url" placeholder="年份"></el-input> -->
- <!-- <el-input
- v-model="dataForm.dateyear"
- :disabled="disabled"
- placeholder="年份"
- ></el-input> -->
- <el-date-picker
- type="year"
- placeholder="选择年份"
- v-model="dataForm.cropName"
- style="width: 100%"
- format="yyyy"
- value-format="yyyy"
- :disabled="disabled"
- ></el-date-picker>
- </el-form-item>
- <el-form-item v-if="dataForm.type === 0 || 1"
- label="开始时间"
- prop=""
- :rules="[
- { required: true, message: '请选择开始时间', trigger: 'blur' },
- ]" >
- <el-date-picker
- v-model="dataForm."
- type="date"
- placeholder="开始时间"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item v-if="dataForm.type === 0 || 1"
- label="截止时间"
- prop=""
- :rules="[
- { required: true, message: '请选择截止时间', trigger: 'blur' },
- ]" >
- <el-date-picker
- v-model="dataForm."
- type="date"
- placeholder="截止时间"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item v-if="dataForm.type === 0 || 1"
- label="填报单位"
- prop=""
- :rules="[
- { required: true, message: '请填写填报单位', trigger: 'blur' },
- ]"
- style="width: 65%" >
- <el-input
- v-model="dataForm."
- :disabled="disabled"
- maxlength="50"
- placeholder="填报单位"
- ></el-input>
- </el-form-item>
- <el-form-item v-if="dataForm.type === 1"
- label="填报状态"
- prop=""
- :rules="[
- { required: true, message: '请填写填报状态', trigger: 'blur' },
- ]"
- style="width: 65%" >
- <el-input
- v-model="dataForm."
- :disabled="disabled"
- maxlength="50"
- placeholder="填报状态"
- ></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="visible = false">取消</el-button>
- <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
- </span>
- </el-dialog>
- </template>
-
- <script>
- data(){
- return{
- visible: false,
- dataForm: {
- id: '',
- type: 1,
- typeList: ['任务', '任务列表'],
- name:'',
- parentName: '',
- },
- dataRule: {
- name: [
- { required: true, message: '名称不能为空', trigger: 'blur' }
- ]
- },
- menuList: [],
- menuListTreeProps: {
- label: 'name',
- children: 'children'
- }
- }
- },
- methods{
- init (id) {
- this.dataForm.id = id || 0
- this.$http({
- url: '/sys/menu/select',
- method: 'get'
- }).then(({ data }) => {
- this.menuList = this.treeDataTranslate(data.menuList, 'menuId')
- }).then(() => {
- this.visible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].resetFields()
- })
- }).then(() => {
- if (this.dataForm.id) {
- this.$http({
- url: `/sys/menu/info/${this.dataForm.id}`,
- method: 'get'
- }).then(({ data }) => {
- if (data && data.code === 0) {
-
- }
- })
- } else {
- this.dataForm.parentName = ''
- }
- })
- },
- // 菜单树选中
- menuListTreeCurrentChangeHandle (data, node) {
- this.dataForm.parentId = data.menuId
- this.dataForm.parentName = data.name
- this.visiblePopover = false
- },
- // 表单提交
- dataFormSubmit () {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.$http({
- url: `/sys/menu/${!this.dataForm.id ? 'save' : 'update'}`,
- method: 'post',
- data: {
-
- }
- }).then(({ data }) => {
- if (data && data.code === 0) {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500
- })
- this.visible = false
- this.$emit('refreshDataList')
- }
- })
- }
- })
- }
- }
- </script>
这个项目这样写逻辑上是没错的,但是跟宽哥交流后,他说我不用这么麻烦,给每一个页面都手动去添加这两个页面。
这两个表应该是固定地分配到每一个任务上.表格里的其他字段,同时包括这两个表的二级菜单里的授权状态和填报和查看。都是后台给你返回数据的。
但是目前没有,你先借用这里面的数据接口进行一个显示,等后台有数据了之后就能直接给你传数据了。
操作的任务里的修改和删除 还有表格的填报和查看都是写在同一列的,不同菜单显示的按钮不同,这里需要用一个判断。这个判断如何做。
包括这个状态填报。它是怎么判断的条件。后台也会传给我?
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。