| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- <style scoped>
- .user-panel {
- margin: 10px auto;
- }
- </style>
- <template>
- <el-dialog
- :visible.sync="showDialog"
- :title="title"
- :modal-append-to-body="false"
- style="text-align: left"
- @close="closeDialog"
- :close-on-click-modal="false"
- >
- <div class="user-panel" v-loading="loading">
- <el-form
- ref="form"
- :model="formModel"
- :rules="ruleValidate"
- :label-width="'130px'"
- >
- <el-form-item label="申请者公司" prop="applicationCompanyId">
- <el-select-tree
- :props="props"
- :options="companyResult"
- v-model="formModel.applicationCompanyId"
- size=""
- height="200"
- ></el-select-tree>
- </el-form-item>
- <el-form-item label="申请者角色" prop="applicationRoleId">
- <el-select
- v-model="formModel.applicationRoleId"
- filterable
- placeholder="请选择"
- style="width: 280px"
- >
- <el-option
- v-for="role in applicationRoleResult"
- :key="role.id"
- :label="role.personRoleName"
- :value="role.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="审核人公司" prop="examineCompanyId">
- <el-select-tree
- :props="props"
- :options="companyResult"
- v-model="formModel.examineCompanyId"
- size=""
- height="200"
- ></el-select-tree>
- </el-form-item>
- <el-form-item label="审核人角色" prop="examineRoleId">
- <el-select
- v-model="formModel.examineRoleId"
- filterable
- placeholder="请选择"
- style="width: 280px"
- >
- <el-option
- v-for="role in examineRoleResult"
- :key="role.id"
- :label="role.personRoleName"
- :value="role.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="审批类型" prop="type">
- <el-select
- v-model="formModel.type"
- filterable
- placeholder="请选择"
- style="width: 280px"
- >
- <el-option
- v-for="result in examineTypeResult"
- :key="result.value"
- :label="result.name"
- :value="result.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="审批等级" prop="level">
- <el-input-number
- v-model="formModel.level"
- placeholder="请输入备注信息"
- style="width: 300px"
- min="1"
- ></el-input-number>
- </el-form-item>
- <el-form-item label="请假天数" prop="days">
- <el-input-number
- v-model="formModel.days"
- placeholder="请输入备注信息"
- style="width: 300px"
- ></el-input-number>
- </el-form-item>
- <el-form-item label="备注信息" prop="remark">
- <el-input
- v-model="formModel.remark"
- placeholder="请输入备注信息"
- style="width: 300px"
- ></el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeDialog">取 消</el-button>
- <el-button type="primary" @click="handleSubmit" :loading="submitting"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </template>
- <script>
- import Constant from "@/constant";
- import applicationExamineApi from "@/api/base/applicationExamine";
- import companyInfoApi from "@/api/base/companyInfo";
- import dataDictionaryApi from "@/api/sys/dataDictionary";
- import personRoleInfoApi from "@/api/base/personRoleInfo";
- import SelectTree from "@/components/SelectTree";
- export default {
- components: {
- "el-select-tree": SelectTree,
- },
- props: ["businessKey", "title"],
- data() {
- return {
- formModel: {},
- ruleValidate: {
- applicationRoleId: [
- { required: true, message: "申请者角色不能为空", trigger: "blur" },
- ],
- applicationCompanyId: [
- { required: true, message: "申请者公司不能为空", trigger: "blur" },
- ],
- examineRoleId: [
- { required: true, message: "审核人角色不能为空", trigger: "blur" },
- ],
- examineCompanyId: [
- { required: true, message: "审核人公司不能为空", trigger: "blur" },
- ],
- type: [
- { required: true, message: "请选择审批类型", trigger: "blur" },
- ]
- },
- showDialog: true,
- loading: false,
- submitting: false,
- treeData: [],
- props: {
- // 配置项(必选)
- value: "id",
- label: "name",
- children: "children",
- },
- applicationRoleResult: [],
- examineRoleResult: [],
- companyResult: [],
- examineTypeResult: [],
- };
- },
- created() {
- var self = this;
- companyInfoApi.list().then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- if (jsonData.data != null && jsonData.data != "") {
- self.companyResult = jsonData.data;
- }
- }
- });
- var formData = new FormData();
- formData.append("catalogName", "审批类型");
- dataDictionaryApi.findByCatalogName(formData).then((response) => {
- var jsonData = response.data;
- this.examineTypeResult = jsonData.data;
- });
- },
- watch: {
- "formModel.applicationCompanyId": function (val, oldval) {
- if (val != null && val != "") {
- var self = this;
- var formData = new FormData();
- formData.append("companyId", val);
- personRoleInfoApi.listByCompanyId(formData).then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- if (jsonData.data != null && jsonData.data != "") {
- self.applicationRoleResult = jsonData.data;
- // applicationCompanyId
- // applicationRoleId
- // examineCompanyId
- // examineRoleId
- }
- }
- });
- }
- },
- "formModel.examineCompanyId": function (val, oldval) {
- if (val != null && val != "") {
- var self = this;
- var formData = new FormData();
- formData.append("companyId", val);
- personRoleInfoApi.listByCompanyId(formData).then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- if (jsonData.data != null && jsonData.data != "") {
- self.examineRoleResult = jsonData.data;
- // applicationCompanyId
- // applicationRoleId
- // examineCompanyId
- // examineRoleId
- }
- }
- });
- }
- },
- },
- methods: {
- closeDialog() {
- this.$emit("close", false);
- },
- handleSubmit() {
- var self = this;
- this.$refs["form"].validate((valid) => {
- if (valid) {
- (function () {
- var id = self.formModel.id;
- if (id == null || id.length == 0) {
- return applicationExamineApi.add(self.formModel);
- } else {
- return applicationExamineApi.update(self.formModel);
- }
- })().then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- self.$message({
- message: "保存成功!",
- type: "success",
- });
- self.$emit("close", true);
- } else {
- self.$message({
- message: jsonData.message + "",
- type: "warning",
- });
- self.$emit("close", false);
- }
- });
- }
- });
- },
- },
- mounted: function () {
- var self = this;
- (function () {
- if (self.businessKey.length == 0) {
- return applicationExamineApi.create();
- } else {
- return applicationExamineApi.edit(self.businessKey);
- }
- })()
- .then((response) => {
- var jsonData = response.data;
- self.loading = false;
- if (jsonData.result) {
- self.formModel = jsonData.data;
- } else {
- self.$message.error(jsonData.message + "");
- }
- })
- .catch((error) => {
- self.$message.error(error + "");
- });
- },
- };
- </script>
|