patrolAdd.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <div class="formContent">
  3. <el-form
  4. ref="formData"
  5. :model="formData"
  6. :rules="rules"
  7. label-width="85px"
  8. class="demo-ruleForm"
  9. >
  10. <div class="formContent-item_title">巡更类型定义</div>
  11. <template>
  12. <el-row>
  13. <el-col :span="24">
  14. <el-form-item
  15. label="所属社区"
  16. prop="communityId"
  17. class="show-required-icon-star"
  18. >
  19. <el-select
  20. v-model="formData.communityId"
  21. placeholder="请选择社区"
  22. >
  23. <el-option
  24. v-for="(item,index) in communityList"
  25. :value="item.value"
  26. :label="item.label"
  27. :key="index"
  28. >
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="24">
  34. <el-form-item
  35. label="巡更类型"
  36. prop="patrolType"
  37. class="show-required-icon-star"
  38. >
  39. <el-select
  40. v-model="formData.patrolType"
  41. placeholder="请选择巡更类型"
  42. @change="patrolTypeClick"
  43. >
  44. <el-option
  45. v-for="(item,index) in patrolTypeList"
  46. :key="index"
  47. :label="item.label"
  48. :value="item.value"
  49. >
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. </template>
  56. <div class="formContent-item_title">巡更内容定义</div>
  57. <!-- <template slot-scope="scope"> -->
  58. <div class="scrollBar">
  59. <el-row
  60. v-for="(items,indexs) in formData.contentDtoList"
  61. :key="indexs"
  62. >
  63. <el-col :span="12">
  64. <el-form-item
  65. label="巡更内容"
  66. :prop="'contentDtoList.'+indexs+'.content'"
  67. :rules="rules.content"
  68. class="show-required-icon-star"
  69. >
  70. <!-- :required="!item.content" -->
  71. <el-input
  72. v-model="formData.contentDtoList[indexs].content"
  73. placeholder="请输入巡更内容"
  74. clearable
  75. ></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="10">
  79. <el-form-item
  80. label="选项组成"
  81. class="show-required-icon-star"
  82. style="margin-right: 5px;"
  83. >
  84. <el-select
  85. v-model="formData.contentDtoList[indexs].optionValue"
  86. placeholder="请选择"
  87. >
  88. <el-option
  89. v-for="(itemd,inded) in optionComposition"
  90. :key="inded"
  91. :value="itemd.value"
  92. :label="itemd.label"
  93. >
  94. </el-option>
  95. </el-select>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="2">
  99. <el-tooltip
  100. effect="light"
  101. placement="bottom"
  102. content="添加"
  103. style="margin-right: 10px; "
  104. v-if="(formData.contentDtoList.length - 1) == indexs ? true : false"
  105. >
  106. <i
  107. class="zoniot_font zoniot-icon-tianjia1"
  108. @click="add"
  109. ></i>
  110. </el-tooltip>
  111. <el-tooltip
  112. effect="light"
  113. placement="bottom"
  114. content="删除"
  115. >
  116. <i
  117. class="zoniot_font zoniot-icon-shanjian"
  118. @click="deleteOne(indexs)"
  119. ></i>
  120. </el-tooltip>
  121. </el-col>
  122. </el-row>
  123. </div>
  124. </el-form>
  125. </div>
  126. </template>
  127. <script>
  128. export default {
  129. props: ['params'],
  130. data () {
  131. return {
  132. formData: {
  133. communityId: '',
  134. patrolType: '',
  135. contentDtoList: [
  136. {
  137. content: '',
  138. optionValue: ''
  139. }
  140. ]
  141. },
  142. communityList: [],
  143. patrolTypeList: [
  144. {
  145. label: '市容市貌',
  146. value: 1
  147. },
  148. {
  149. label: '环境卫生',
  150. value: 2
  151. },
  152. {
  153. label: '公共秩序',
  154. value: 3
  155. },
  156. {
  157. label: '设备设施',
  158. value: 4
  159. },
  160. {
  161. label: '消防安全',
  162. value: 5
  163. },
  164. ],
  165. optionComposition: [
  166. {
  167. label: '是、否',
  168. value: '是、否'
  169. },
  170. {
  171. label: '坏、好',
  172. value: '坏、好'
  173. },
  174. {
  175. label: '有、无',
  176. value: '有、无',
  177. },
  178. {
  179. label: '差、好',
  180. value: '差、好'
  181. }
  182. ],
  183. rules: {
  184. communityId: [{ required: true, message: '请输入所属社区', trigger: 'change' },],
  185. patrolType: [{ required: true, message: '请输入巡更类型', trigger: 'change' },],
  186. content: { required: true, message: '请输入巡更内容', trigger: 'blur' },
  187. }
  188. }
  189. },
  190. methods: {
  191. patrolTypeClick () {
  192. this.$http.post('/czc-community/patrol/standard/list/content', { communityId: this.formData.communityId, patrolType: this.formData.patrolType }).then(({ status, data, msg }) => {
  193. if (status == 0) {
  194. if (data.length != 0) {
  195. this.formData.contentDtoList = [];
  196. data.map((item, index) => {
  197. this.formData.contentDtoList.push(
  198. {
  199. content: item.content,
  200. optionValue: item.optionValue
  201. }
  202. )
  203. })
  204. } else {
  205. this.formData.contentDtoList = [];
  206. this.formData.contentDtoList.push({
  207. content: '',
  208. optionValue: ''
  209. })
  210. }
  211. }
  212. })
  213. },
  214. getOrgTreeList () {
  215. this.$http.get('/czc-community/assets/community/list').then(({ status, data, msg }) => {
  216. if (status == 0) {
  217. this.communityList = [];
  218. data.map((item, index) => {
  219. this.communityList.push({
  220. label: item.communityName,
  221. value: item.id
  222. })
  223. });
  224. }
  225. })
  226. },
  227. submit () {
  228. this.$refs.formData.validate((valid) => {
  229. if (valid) {
  230. let url = ''
  231. if (this.params.rowId == '1') {
  232. url = '/czc-community/patrol/standard/update'
  233. } else {
  234. url = '/czc-community/patrol/standard/add'
  235. }
  236. this.$http.post(url, this.formData).then(({ status, data, msg }) => {
  237. this.$message.success(msg);
  238. this.params.callback();
  239. this.$emit('close');
  240. })
  241. } else {
  242. return;
  243. }
  244. })
  245. },
  246. add () {
  247. this.formData.contentDtoList.push(
  248. {
  249. content: '',
  250. optionValue: ''
  251. }
  252. )
  253. },
  254. deleteOne (id) {
  255. if (this.formData.contentDtoList.length != 1) {
  256. this.formData.contentDtoList.splice(id, 1);
  257. return;
  258. }
  259. },
  260. },
  261. created () {
  262. this.getOrgTreeList();//获取社区内容
  263. debugger;
  264. if (this.params.rowId == '1') {
  265. this.formData.communityId = this.params.row.communityId;
  266. this.formData.patrolType = this.params.row.patrolType;
  267. this.formData.contentDtoList = [];
  268. this.params.row.contentVos.map((item, index) => {
  269. this.formData.contentDtoList.push({
  270. content: item.content,
  271. optionValue: item.optionValue
  272. })
  273. })
  274. }
  275. }
  276. }
  277. </script>
  278. <style scoped lang='scss'>
  279. .zoniot_font {
  280. line-height: 32px !important;
  281. }
  282. // .scrollBar {
  283. // overflow: hidden;
  284. // overflow-y: auto;
  285. // max-height: 200px;
  286. // }
  287. </style>