applicationExamine-detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <style scoped>
  2. .user-panel {
  3. margin: 10px auto;
  4. }
  5. </style>
  6. <template>
  7. <el-dialog
  8. :visible.sync="showDialog"
  9. :title="title"
  10. :modal-append-to-body="false"
  11. style="text-align: left"
  12. @close="closeDialog"
  13. :close-on-click-modal="false"
  14. >
  15. <div class="user-panel" v-loading="loading">
  16. <el-form
  17. ref="form"
  18. :model="formModel"
  19. :rules="ruleValidate"
  20. :label-width="'130px'"
  21. >
  22. <el-form-item label="申请者公司" prop="applicationCompanyId">
  23. <el-select-tree
  24. :props="props"
  25. :options="companyResult"
  26. v-model="formModel.applicationCompanyId"
  27. size=""
  28. height="200"
  29. ></el-select-tree>
  30. </el-form-item>
  31. <el-form-item label="申请者角色" prop="applicationRoleId">
  32. <el-select
  33. v-model="formModel.applicationRoleId"
  34. filterable
  35. placeholder="请选择"
  36. style="width: 280px"
  37. >
  38. <el-option
  39. v-for="role in applicationRoleResult"
  40. :key="role.id"
  41. :label="role.personRoleName"
  42. :value="role.id"
  43. ></el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="审核人公司" prop="examineCompanyId">
  47. <el-select-tree
  48. :props="props"
  49. :options="companyResult"
  50. v-model="formModel.examineCompanyId"
  51. size=""
  52. height="200"
  53. ></el-select-tree>
  54. </el-form-item>
  55. <el-form-item label="审核人角色" prop="examineRoleId">
  56. <el-select
  57. v-model="formModel.examineRoleId"
  58. filterable
  59. placeholder="请选择"
  60. style="width: 280px"
  61. >
  62. <el-option
  63. v-for="role in examineRoleResult"
  64. :key="role.id"
  65. :label="role.personRoleName"
  66. :value="role.id"
  67. ></el-option>
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="审批类型" prop="type">
  71. <el-select
  72. v-model="formModel.type"
  73. filterable
  74. placeholder="请选择"
  75. style="width: 280px"
  76. >
  77. <el-option
  78. v-for="result in examineTypeResult"
  79. :key="result.value"
  80. :label="result.name"
  81. :value="result.value"
  82. ></el-option>
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="审批等级" prop="level">
  86. <el-input-number
  87. v-model="formModel.level"
  88. placeholder="请输入备注信息"
  89. style="width: 300px"
  90. min="1"
  91. ></el-input-number>
  92. </el-form-item>
  93. <el-form-item label="请假天数" prop="days">
  94. <el-input-number
  95. v-model="formModel.days"
  96. placeholder="请输入备注信息"
  97. style="width: 300px"
  98. ></el-input-number>
  99. </el-form-item>
  100. <el-form-item label="备注信息" prop="remark">
  101. <el-input
  102. v-model="formModel.remark"
  103. placeholder="请输入备注信息"
  104. style="width: 300px"
  105. ></el-input>
  106. </el-form-item>
  107. </el-form>
  108. </div>
  109. <span slot="footer" class="dialog-footer">
  110. <el-button @click="closeDialog">取 消</el-button>
  111. <el-button type="primary" @click="handleSubmit" :loading="submitting"
  112. >确 定</el-button
  113. >
  114. </span>
  115. </el-dialog>
  116. </template>
  117. <script>
  118. import Constant from "@/constant";
  119. import applicationExamineApi from "@/api/base/applicationExamine";
  120. import companyInfoApi from "@/api/base/companyInfo";
  121. import dataDictionaryApi from "@/api/sys/dataDictionary";
  122. import personRoleInfoApi from "@/api/base/personRoleInfo";
  123. import SelectTree from "@/components/SelectTree";
  124. export default {
  125. components: {
  126. "el-select-tree": SelectTree,
  127. },
  128. props: ["businessKey", "title"],
  129. data() {
  130. return {
  131. formModel: {},
  132. ruleValidate: {
  133. applicationRoleId: [
  134. { required: true, message: "申请者角色不能为空", trigger: "blur" },
  135. ],
  136. applicationCompanyId: [
  137. { required: true, message: "申请者公司不能为空", trigger: "blur" },
  138. ],
  139. examineRoleId: [
  140. { required: true, message: "审核人角色不能为空", trigger: "blur" },
  141. ],
  142. examineCompanyId: [
  143. { required: true, message: "审核人公司不能为空", trigger: "blur" },
  144. ],
  145. type: [
  146. { required: true, message: "请选择审批类型", trigger: "blur" },
  147. ]
  148. },
  149. showDialog: true,
  150. loading: false,
  151. submitting: false,
  152. treeData: [],
  153. props: {
  154. // 配置项(必选)
  155. value: "id",
  156. label: "name",
  157. children: "children",
  158. },
  159. applicationRoleResult: [],
  160. examineRoleResult: [],
  161. companyResult: [],
  162. examineTypeResult: [],
  163. };
  164. },
  165. created() {
  166. var self = this;
  167. companyInfoApi.list().then(function (response) {
  168. var jsonData = response.data;
  169. if (jsonData.result) {
  170. if (jsonData.data != null && jsonData.data != "") {
  171. self.companyResult = jsonData.data;
  172. }
  173. }
  174. });
  175. var formData = new FormData();
  176. formData.append("catalogName", "审批类型");
  177. dataDictionaryApi.findByCatalogName(formData).then((response) => {
  178. var jsonData = response.data;
  179. this.examineTypeResult = jsonData.data;
  180. });
  181. },
  182. watch: {
  183. "formModel.applicationCompanyId": function (val, oldval) {
  184. if (val != null && val != "") {
  185. var self = this;
  186. var formData = new FormData();
  187. formData.append("companyId", val);
  188. personRoleInfoApi.listByCompanyId(formData).then(function (response) {
  189. var jsonData = response.data;
  190. if (jsonData.result) {
  191. if (jsonData.data != null && jsonData.data != "") {
  192. self.applicationRoleResult = jsonData.data;
  193. // applicationCompanyId
  194. // applicationRoleId
  195. // examineCompanyId
  196. // examineRoleId
  197. }
  198. }
  199. });
  200. }
  201. },
  202. "formModel.examineCompanyId": function (val, oldval) {
  203. if (val != null && val != "") {
  204. var self = this;
  205. var formData = new FormData();
  206. formData.append("companyId", val);
  207. personRoleInfoApi.listByCompanyId(formData).then(function (response) {
  208. var jsonData = response.data;
  209. if (jsonData.result) {
  210. if (jsonData.data != null && jsonData.data != "") {
  211. self.examineRoleResult = jsonData.data;
  212. // applicationCompanyId
  213. // applicationRoleId
  214. // examineCompanyId
  215. // examineRoleId
  216. }
  217. }
  218. });
  219. }
  220. },
  221. },
  222. methods: {
  223. closeDialog() {
  224. this.$emit("close", false);
  225. },
  226. handleSubmit() {
  227. var self = this;
  228. this.$refs["form"].validate((valid) => {
  229. if (valid) {
  230. (function () {
  231. var id = self.formModel.id;
  232. if (id == null || id.length == 0) {
  233. return applicationExamineApi.add(self.formModel);
  234. } else {
  235. return applicationExamineApi.update(self.formModel);
  236. }
  237. })().then(function (response) {
  238. var jsonData = response.data;
  239. if (jsonData.result) {
  240. self.$message({
  241. message: "保存成功!",
  242. type: "success",
  243. });
  244. self.$emit("close", true);
  245. } else {
  246. self.$message({
  247. message: jsonData.message + "",
  248. type: "warning",
  249. });
  250. self.$emit("close", false);
  251. }
  252. });
  253. }
  254. });
  255. },
  256. },
  257. mounted: function () {
  258. var self = this;
  259. (function () {
  260. if (self.businessKey.length == 0) {
  261. return applicationExamineApi.create();
  262. } else {
  263. return applicationExamineApi.edit(self.businessKey);
  264. }
  265. })()
  266. .then((response) => {
  267. var jsonData = response.data;
  268. self.loading = false;
  269. if (jsonData.result) {
  270. self.formModel = jsonData.data;
  271. } else {
  272. self.$message.error(jsonData.message + "");
  273. }
  274. })
  275. .catch((error) => {
  276. self.$message.error(error + "");
  277. });
  278. },
  279. };
  280. </script>