MrShi
2024-11-07 bf2338f5cc71890cda247d46edcffa42e21871f6
company/src/components/system/user/OperaUserWindow.vue
@@ -23,6 +23,14 @@
          <el-button type="primary" style="flex-shrink: 0; margin-left: 15px;" v-else>{{num}}s</el-button>
        </div>
      </el-form-item>
      <el-form-item label="部门" prop="departmentId">
        <el-cascader
          :options="organization"
          v-model="form.departmentId"
          placeholder="请选择"
          :props="{ label: 'name', value: 'id', checkStrictly: true }"
          clearable />
      </el-form-item>
      <el-form-item label="抄送文件邮箱" prop="email">
        <el-input v-model="form.email" placeholder="请输入" v-trim />
      </el-form-item>
@@ -37,7 +45,7 @@
import PositionSelect from '@/components/common/PositionSelect'
import { checkMobile, checkEmail } from '@/utils/form'
import { sendSms } from '@/api/business/smsEmail'
import { tree } from '@/api/business/companyDepartment'
export default {
  name: 'OperaUserWindow',
  extends: BaseOpera,
@@ -51,10 +59,12 @@
        realname: '', // 姓名
        mobile: '', // 手机号码
        email: '',
        captcha: ''
        captcha: '',
        departmentId: ''
      },
      num: 0,
      timer: null,
      organization: [],
      // 验证规则
      rules: {
        username: [
@@ -66,6 +76,9 @@
        mobile: [
          { required: true, validator: checkMobile }
        ],
        departmentId: [
          { required: true, message: '请选择部门' }
        ],
        email: [
          { required: true, message: '请输入邮箱' }
        ]
@@ -73,6 +86,52 @@
    }
  },
  methods: {
    __confirmCreate () {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        let obj = JSON.parse(JSON.stringify(this.form))
        obj.departmentId = obj.departmentId[0]
        // 调用新建接口
        this.isWorking = true
        this.api.create(obj)
          .then(() => {
            this.visible = false
            this.$tip.apiSuccess('新建成功')
            this.$emit('success')
          })
          .catch(e => {
            this.$tip.apiFailed(e)
          })
          .finally(() => {
            this.isWorking = false
          })
      })
    },
    __confirmEdit () {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        let obj = JSON.parse(JSON.stringify(this.form))
        obj.departmentId = obj.departmentId[0]
        // 调用新建接口
        this.isWorking = true
        this.api.updateById(obj)
          .then(() => {
            this.visible = false
            this.$tip.apiSuccess('修改成功')
            this.$emit('success')
          })
          .catch(e => {
            this.$tip.apiFailed(e)
          })
          .finally(() => {
            this.isWorking = false
          })
      })
    },
    send() {
      if (!this.form.mobile) {
        this.$message.warning('请输入手机号')
@@ -82,6 +141,12 @@
        .then(res => {
          this.num = 60
          this.setTime()
        })
    },
    getTree() {
      tree()
        .then(records => {
          this.organization = records
        })
    },
    setTime() {
@@ -100,6 +165,7 @@
    open (title, target) {
      this.title = title
      this.visible = true
      this.getTree()
      clearInterval(this.timer)
      this.num = 0
      // 新建
@@ -107,8 +173,8 @@
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form.id = null
          this.form.departmentId = null
          this.form.positionIds = []
          // this.form.departmentId = null
          // this.form.positionIds = []
        })
        return
      }
@@ -117,8 +183,8 @@
        for (const key in this.form) {
          this.form[key] = target[key]
        }
        this.form.departmentId = target.department == null ? null : target.department.id
        this.form.positionIds = target.positions == null ? [] : target.positions.map(p => p.id)
        // this.form.departmentId = target.department == null ? null : target.department.id
        // this.form.positionIds = target.positions == null ? [] : target.positions.map(p => p.id)
      })
    }
  },