AddOrEdit.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <!--
  2. * @Author: zwy
  3. * @Date: 2021-02-01 11:46:07
  4. * @LastEditors: zwy
  5. * @LastEditTime: 2021-03-11 11:16:24
  6. * @Descripttion: 工作流管理-编辑弹框
  7. -->
  8. <template>
  9. <div class="flowModal">
  10. <div
  11. class="tree-style"
  12. v-if="params.todo == 'add'"
  13. >
  14. <el-checkbox-group v-model="formData.companyIds">
  15. <el-checkbox
  16. v-for="item in organList"
  17. :label="item.id"
  18. :key="item.id"
  19. >{{ item.communityName }}</el-checkbox>
  20. </el-checkbox-group>
  21. </div>
  22. <zz-form
  23. class="form"
  24. :cols="formCols"
  25. :data="formData"
  26. :rules="formRules"
  27. labelWidth="100"
  28. ref="form"
  29. >
  30. <template slot="businessType">
  31. <el-select
  32. v-model="formData.businessType"
  33. placeholder="请选择业务类型"
  34. @change="changeBusinessType"
  35. >
  36. <el-option
  37. label="安保巡更"
  38. :value="1"
  39. ></el-option>
  40. <el-option
  41. label="设备巡检"
  42. :value="2"
  43. ></el-option>
  44. <el-option
  45. label="运维工单"
  46. :value="3"
  47. ></el-option>
  48. <el-option
  49. label="收费管理"
  50. :value="4"
  51. ></el-option>
  52. </el-select>
  53. </template>
  54. <template slot="taskType">
  55. <el-select
  56. v-model="formData.taskType"
  57. placeholder="请选择任务类型"
  58. >
  59. <el-option
  60. v-for="(item, index) in taskTypeList"
  61. :key="index"
  62. :value="+item.dictCode"
  63. :label="item.dictValue"
  64. ></el-option>
  65. </el-select>
  66. </template>
  67. </zz-form>
  68. </div>
  69. </template>
  70. <script>
  71. export default {
  72. props: ['params'],
  73. data () {
  74. return {
  75. formType: [],
  76. organList: [],
  77. defaultProps: {
  78. children: 'orgs',
  79. label: 'communityName'
  80. },
  81. formData: {
  82. processName: '',
  83. businessType: '',
  84. taskType: '',
  85. companyIds: [],
  86. id: '',
  87. processDesc: '',
  88. companyOrgId: ''
  89. },
  90. taskTypeList: [],
  91. formCols: [
  92. [
  93. {
  94. label: '名称',
  95. prop: 'processName',
  96. input: true
  97. },
  98. {
  99. label: '业务类型',
  100. prop: 'businessType',
  101. slot: 'businessType'
  102. },
  103. {
  104. label: '任务类型',
  105. prop: 'taskType',
  106. slot: 'taskType'
  107. },
  108. {
  109. label: '描述',
  110. prop: 'processDesc',
  111. input: true
  112. }
  113. ]
  114. ],
  115. formRules: {
  116. processName: [this.$valid.inputRequired('名称')],
  117. businessType: [this.$valid.selectRequired('业务类型')],
  118. taskType: [this.$valid.selectRequired('业务类型')]
  119. }
  120. };
  121. },
  122. methods: {
  123. getOrgTreeList () {
  124. this.$http.get('/czc-community/assets/community/list').then(({ status, data, msg }) => {
  125. if (status === 0 && data) {
  126. this.organList = data;
  127. // this.$nextTick().then(() => {
  128. // const firstNode = document.querySelector('.el-tree-node');
  129. // firstNode.click();
  130. // });
  131. }
  132. });
  133. },
  134. getTaskType (typeKey) {
  135. this.$api.common.getDictionaryData(typeKey).then(({ msg, status, data }) => {
  136. if (status == 0) {
  137. this.taskTypeList = data;
  138. }
  139. });
  140. },
  141. submit () {
  142. new Promise((resolve) => {
  143. this.$refs.form.validate(resolve);
  144. }).then(() => {
  145. var posturl = '',
  146. method = 'post';
  147. if (this.params.todo === 'edit') {
  148. method = 'put';
  149. posturl = '/czc-community/workflow/process/edit';
  150. delete this.formData.companyIds;
  151. } else {
  152. posturl = '/czc-community/workflow/process/add';
  153. if (!this.formData.companyIds.length) {
  154. this.$message.error('请勾选所属社区');
  155. loading.close();
  156. return;
  157. }
  158. }
  159. var loading = this.$loading();
  160. this.$http[method](posturl, this.formData)
  161. .then(({ status, data, msg }) => {
  162. loading.close();
  163. if (0 == status) {
  164. this.$message.success(msg);
  165. this.params.callback && this.params.callback();
  166. this.$emit('close');
  167. } else {
  168. this.$message.error(msg);
  169. }
  170. })
  171. .catch((err) => {
  172. this.$message.error(err);
  173. loading.close();
  174. });
  175. });
  176. },
  177. changeBusinessType () {
  178. this.formData.taskType = '';
  179. switch (this.formData.businessType) {
  180. case 1:
  181. // this.getWorkList();
  182. this.getTaskType('SC_SECURITY_PATROL');
  183. break;
  184. case 2:
  185. // this.getTaskList();
  186. this.getTaskType('SC_EQUIPMENT_INSPECTION');
  187. break;
  188. case 3:
  189. this.getTaskType('SC_WORK_ORDER_TYPE');
  190. break;
  191. case 4:
  192. this.getTaskType('CZC_CHARGE_TYPE');
  193. }
  194. }
  195. },
  196. created () {
  197. this.getOrgTreeList();
  198. if (this.params.todo == 'edit') {
  199. this.__setValue('formData');
  200. this.formData.communityId = this.params.data.communityId;
  201. switch (this.formData.businessType) {
  202. case 1:
  203. // this.getWorkList();
  204. this.getTaskType('SC_SECURITY_PATROL');
  205. break;
  206. case 2:
  207. // this.getTaskList();
  208. this.getTaskType('SC_EQUIPMENT_INSPECTION');
  209. break;
  210. case 3:
  211. // this.getTaskType();
  212. this.getTaskType('SC_WORK_ORDER_TYPE');
  213. break;
  214. case 4:
  215. this.getTaskType('CZC_CHARGE_TYPE');
  216. }
  217. }
  218. }
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .flowModal {
  223. display: flex;
  224. height: 100%;
  225. .tree-style {
  226. width: 340px;
  227. height: 100%;
  228. border: 1px solid #d8d8d8;
  229. border-radius: 4px;
  230. overflow: auto;
  231. padding: 20px;
  232. /deep/ .el-checkbox {
  233. line-height: 26px;
  234. display: block;
  235. }
  236. }
  237. .form {
  238. height: 100%;
  239. width: 100%;
  240. margin-left: 20px;
  241. border: 1px solid #d8d8d8;
  242. padding: 20px;
  243. }
  244. }
  245. </style>