AddOrEdit.vue 7.0 KB

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