approvalConfig-detail.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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="'150px'"
  21. >
  22. <el-form-item label="公司" prop="companyId">
  23. <el-select-tree
  24. :props="props"
  25. :options="companyResult"
  26. v-model="formModel.companyId"
  27. size=""
  28. height="200"
  29. ></el-select-tree>
  30. </el-form-item>
  31. <el-form-item
  32. label="类型"
  33. prop="type"
  34. >
  35. <el-select
  36. v-model="formModel.type"
  37. filterable
  38. placeholder="请选择"
  39. style="width: 200px"
  40. >
  41. <el-option
  42. v-for="type in typeResult"
  43. :key="type.value"
  44. :label="type.name"
  45. :value="type.value"
  46. ></el-option>
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item label="审批层级" prop="level">
  50. <el-input-number
  51. v-model="formModel.level"
  52. placeholder="请输入审批需要的层级"
  53. style="width: 200px"
  54. :min="0" :max="99"
  55. ></el-input-number>
  56. </el-form-item>
  57. <el-form-item label="申请对应天数" prop="days">
  58. <el-input-number
  59. v-model="formModel.days"
  60. placeholder="请输入申请时对应的天数"
  61. style="width: 200px"
  62. :min="0" :max="99"
  63. ></el-input-number>
  64. </el-form-item>
  65. <el-form-item label="备注信息" prop="remark">
  66. <el-input
  67. v-model="formModel.remark"
  68. placeholder="请输入备注信息"
  69. style="width: 400px"
  70. ></el-input>
  71. </el-form-item>
  72. </el-form>
  73. </div>
  74. <span slot="footer" class="dialog-footer">
  75. <el-button @click="closeDialog">取 消</el-button>
  76. <el-button type="primary" @click="handleSubmit" :loading="submitting"
  77. >确 定</el-button
  78. >
  79. </span>
  80. </el-dialog>
  81. </template>
  82. <script>
  83. import Constant from "@/constant";
  84. import approvalConfigApi from "@/api/base/approvalConfig";
  85. import companyInfoApi from "@/api/base/companyInfo";
  86. import dataDictionaryApi from "@/api/sys/dataDictionary";
  87. import SelectTree from "@/components/SelectTree";
  88. export default {
  89. props: ["businessKey", "title"],
  90. components: {
  91. "el-select-tree": SelectTree
  92. },
  93. data() {
  94. return {
  95. formModel: {},
  96. ruleValidate: {
  97. companyId: [
  98. { required: true, message: "请选择单位", trigger: "blur" },
  99. ],
  100. type: [
  101. {
  102. required: true,
  103. message:
  104. "请选择类型",
  105. trigger: "blur",
  106. },
  107. ],
  108. level: [
  109. {
  110. required: true,
  111. message: "审批需要的层级不能为空",
  112. trigger: "blur",
  113. },
  114. ],
  115. days: [
  116. {
  117. required: true,
  118. message: "申请时对应的天数不能为空",
  119. trigger: "blur",
  120. },
  121. ],
  122. },
  123. showDialog: true,
  124. loading: false,
  125. submitting: false,
  126. companyResult: [],
  127. treeData: [],
  128. props: {
  129. // 配置项(必选)
  130. value: "id",
  131. label: "name",
  132. children: "children",
  133. },
  134. typeResult: [],
  135. };
  136. },
  137. created() {
  138. var self = this;
  139. companyInfoApi.treeList().then(function (response) {
  140. var jsonData = response.data;
  141. if (jsonData.result) {
  142. if (jsonData.data != null && jsonData.data != "") {
  143. self.companyResult = jsonData.data;
  144. }
  145. }
  146. });
  147. dataDictionaryApi
  148. .findByCatalogName({
  149. catalogName: "审批层级类型",
  150. })
  151. .then((response) => {
  152. var jsonData = response.data;
  153. this.typeResult = jsonData.data;
  154. });
  155. },
  156. methods: {
  157. closeDialog() {
  158. this.$emit("close", false);
  159. },
  160. handleSubmit() {
  161. var self = this;
  162. this.$refs["form"].validate((valid) => {
  163. if (valid) {
  164. (function () {
  165. var id = self.formModel.id;
  166. if (id == null || id.length == 0) {
  167. return approvalConfigApi.add(self.formModel);
  168. } else {
  169. return approvalConfigApi.update(self.formModel);
  170. }
  171. })().then(function (response) {
  172. var jsonData = response.data;
  173. if (jsonData.result) {
  174. self.$message({
  175. message: "保存成功!",
  176. type: "success",
  177. });
  178. self.$emit("close", true);
  179. } else {
  180. self.$message({
  181. message: jsonData.message + "",
  182. type: "warning",
  183. });
  184. self.$emit("close", false);
  185. }
  186. });
  187. }
  188. });
  189. },
  190. },
  191. mounted: function () {
  192. var self = this;
  193. (function () {
  194. if (self.businessKey.length == 0) {
  195. return approvalConfigApi.create();
  196. } else {
  197. return approvalConfigApi.edit(self.businessKey);
  198. }
  199. })()
  200. .then((response) => {
  201. var jsonData = response.data;
  202. self.loading = false;
  203. if (jsonData.result) {
  204. self.formModel = jsonData.data;
  205. } else {
  206. self.$message.error(jsonData.message + "");
  207. }
  208. })
  209. .catch((error) => {
  210. self.$message.error(error + "");
  211. });
  212. },
  213. };
  214. </script>