123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <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="name">
- <el-input v-model="dataForm.name" placeholder="机构名称"></el-input>
- </el-form-item>
- <el-form-item label="上级机构" prop="parentName">
- <el-popover
- ref="menuListPopover"
- placement="bottom-start"
- trigger="click">
- <el-tree
- :data="orgList"
- :props="menuListTreeProps"
- node-key="menuId"
- ref="menuListTree"
- @current-change="menuListTreeCurrentChangeHandle"
- :default-expand-all="true"
- :highlight-current="true"
- :expand-on-click-node="false">
- </el-tree>
- </el-popover>
- <el-input v-model="dataForm.parentName" v-popover:menuListPopover :readonly="true" placeholder="点击选择上级机构" class="menu-list__input"></el-input>
- </el-form-item>
- <!-- <el-form-item label="状态" size="mini" prop="orgType">
- <el-radio-group v-model="dataForm.orgType">
- <el-radio :label="0">非运输公司</el-radio>
- <el-radio :label="1">运输公司</el-radio>
- </el-radio-group>
- </el-form-item> -->
- <el-form-item label="排序" prop="orderNum">
- <el-input-number v-model="dataForm.orderNum" controls-position="right" :min="0" label="排序"></el-input-number>
- </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>
- export default {
- data () {
- return {
- visible: false,
- orgList: [],
- dataForm: {
- id: 0,
- name: '',
- parentId: '',
- parentName: '',
- orderNum: '',
- orgType: ''
- },
- dataRule: {
- name: [
- { required: true, message: '机构名称不能为空', trigger: 'blur' }
- ],
- parentName: [
- { required: true, message: '上级机构不能为空', trigger: 'change' }
- ]
- },
- menuListTreeProps: {
- label: 'name',
- children: 'children'
- }
- }
- },
- methods: {
- async init (id) {
- this.dataForm.id = id || 0
- this.$http({
- url: this.$http.adornUrl(`/user-service/org/queryTree`),
- method: 'get',
- params: this.$http.adornParams()
- }).then(({data}) => {
- this.orgList = data && data.code === '200' ? data.data : []
- }).then(() => {
- this.visible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].resetFields()
- })
- }).then(() => {
- if (this.dataForm.id) {
- this.$http({
- url: this.$http.adornUrl(`/user-service/org/info/${this.dataForm.id}`),
- method: 'get',
- params: this.$http.adornParams()
- }).then(({data}) => {
- if (data && data.code === 0) {
- this.dataForm.userName = data.user.username
- this.dataForm.salt = data.user.salt
- this.dataForm.email = data.user.email
- this.dataForm.mobile = data.user.mobile
- this.dataForm.roleIdList = data.user.roleIdList
- this.dataForm.status = data.user.status
- }
- })
- }
- })
- },
- menuListTreeCurrentChangeHandle (data, node) {
- this.dataForm.parentId = data.orgId
- this.dataForm.parentName = data.name
- },
- // 表单提交
- dataFormSubmit () {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- const params = { ...this.dataForm }
- if (this.dataForm.id) params.orgId = this.dataForm.id
- this.$http({
- url: this.$http.adornUrl(`/user-service/org/save`),
- method: this.dataForm.id ? 'put' : 'post',
- data: this.$http.adornData(params)
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.visible = false
- this.$emit('refreshDataList')
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }
- })
- }
- }
- }
- </script>
|