addPatrol.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="main">
  3. <div class="blockName">
  4. {{ !isAdd ? '编辑' : '新增' }}巡更路线(
  5. <span class="show-required-icon-star"></span>为必填项)
  6. </div>
  7. <el-form
  8. :model="ruleForm"
  9. :rules="rules"
  10. ref="ruleForm"
  11. label-width="120px"
  12. class="formContent"
  13. >
  14. <div class="formContent-item">
  15. <el-form-item label="所属社区" prop="communityId">
  16. <el-select
  17. class="width100"
  18. v-model="ruleForm.communityId"
  19. placeholder="所属社区"
  20. clearable
  21. >
  22. <el-option
  23. v-for="(item, index) in $parent.communityArr"
  24. :key="index"
  25. :label="item.communityName"
  26. :value="item.id"
  27. ></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="巡更路线名称" prop="routeName">
  31. <el-input v-model="ruleForm.routeName" placeholder="请输入巡更路线名称"></el-input>
  32. </el-form-item>
  33. <el-form-item label="巡更点" prop="routePointRelationDtos">
  34. <el-transfer
  35. v-model="ruleForm.routePointRelationDtos"
  36. ref="transferTude"
  37. filterable
  38. :props="{
  39. key: 'id',
  40. label: 'pointName',
  41. lan: 'latitude',
  42. lng: 'longitude'
  43. }"
  44. :titles="['待选列表', '已选列表']"
  45. @change="handleChange"
  46. :data="patrolArr"
  47. ></el-transfer>
  48. <map-value :point="targetData"></map-value>
  49. </el-form-item>
  50. </div>
  51. <div class="formContent-item">
  52. <el-form-item label="巡更日期" prop="startDate">
  53. <el-date-picker
  54. class="width100"
  55. v-model="effectiveDate"
  56. value-format="yyyy-MM-dd"
  57. type="daterange"
  58. range-separator="至"
  59. start-placeholder="选择开始日期"
  60. end-placeholder="选择结束日期"
  61. @change="effectiveDateToggle"
  62. :editable="false"
  63. ></el-date-picker>
  64. </el-form-item>
  65. <el-form-item label="巡更时间" prop="timePeriod">
  66. <div class="timeList" v-for="(item,index) in timePeriod" :key="index">
  67. <el-time-select
  68. class="width50"
  69. placeholder="开始时间"
  70. v-model="item.startTime"
  71. :picker-options="{
  72. start: '00:00',
  73. step: '00:15',
  74. end: '23:30'
  75. }"
  76. @change="timeChange(item,'startTime')"
  77. ></el-time-select>
  78. <span>至</span>
  79. <el-time-select
  80. placeholder="结束时间"
  81. v-model="item.endTime"
  82. class="width50"
  83. :picker-options="{
  84. start: '00:00',
  85. step: '00:15',
  86. end: '23:30',
  87. minTime: item.startTime
  88. }"
  89. @change="timeChange(item,'endTime')"
  90. ></el-time-select>
  91. <div class="sunm" @click="addTime(index,1)">
  92. <i class="zoniot_font zoniot-icon-tianjia1"></i>
  93. </div>
  94. <div
  95. class="sunm"
  96. @click="addTime(index,-1)"
  97. v-if="timePeriod.length>1 && index!=0"
  98. >
  99. <i class="zoniot_font zoniot-icon-shanjian"></i>
  100. </div>
  101. </div>
  102. </el-form-item>
  103. <el-form-item label="巡更周期" prop="periodValue">
  104. <el-radio-group v-model="ruleForm.periodType">
  105. <el-radio :label="1">每周重复</el-radio>
  106. <el-radio :label="2">间隔天数重复</el-radio>
  107. </el-radio-group>
  108. <el-checkbox-group v-if="ruleForm.periodType == 1" v-model="periodValue">
  109. <el-checkbox :label="1">周一</el-checkbox>
  110. <el-checkbox :label="2">周二</el-checkbox>
  111. <el-checkbox :label="3">周三</el-checkbox>
  112. <el-checkbox :label="4">周四</el-checkbox>
  113. <el-checkbox :label="5">周五</el-checkbox>
  114. <el-checkbox :label="6">周六</el-checkbox>
  115. <el-checkbox :label="7">周日</el-checkbox>
  116. </el-checkbox-group>
  117. <div v-else class="periodValueInput">
  118. 每隔
  119. <el-input-number
  120. v-model="ruleForm.periodValue"
  121. controls-position="right"
  122. :min="0"
  123. :max="30"
  124. ></el-input-number>天进行(输入0-30的数字,0代表每天都要进行任务)
  125. </div>
  126. </el-form-item>
  127. <el-form-item label="定位距离(m)">
  128. <el-input
  129. v-model="ruleForm.positioningDistance"
  130. placeholder="巡更定位距离,可输入1-100米,不输入则不检查定位距离"
  131. ></el-input>
  132. </el-form-item>
  133. <el-form-item label="拍照/视频要求">
  134. <el-select
  135. class="width100"
  136. v-model="ruleForm.cameraSettings"
  137. placeholder="请选择拍照/视频要求"
  138. clearable
  139. >
  140. <el-option label="是" :value="1"></el-option>
  141. <el-option label="否" :value="0"></el-option>
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="备注信息">
  145. <el-input
  146. type="textarea"
  147. placeholder="请输入备注信息"
  148. resize="none"
  149. :rows="4"
  150. v-model="ruleForm.remark"
  151. maxlength="300"
  152. show-word-limit
  153. ></el-input>
  154. </el-form-item>
  155. </div>
  156. </el-form>
  157. <div style="text-align: right">
  158. <el-button @click="close">取消</el-button>
  159. <el-button type="primary" @click="addEdit">保存</el-button>
  160. </div>
  161. </div>
  162. </template>
  163. <script>
  164. import mapValue from './mapValue.vue';
  165. export default {
  166. components: { mapValue },
  167. data() {
  168. return {
  169. ruleForm: {
  170. communityId: '',
  171. routeName: '',
  172. routePointRelationDtos: [],
  173. startDate: '',
  174. endDate: '',
  175. timePeriod: '',
  176. periodType: 1,
  177. periodValue: '',
  178. positioningDistance: '',
  179. cameraSettings: '',
  180. remark: ''
  181. },
  182. periodValue: [],
  183. timePeriod: [
  184. {
  185. startTime: '',
  186. endTime: ''
  187. }
  188. ],
  189. rules: {
  190. communityId: [this.$valid.inputRequired('社区名称')],
  191. routeName: [this.$valid.inputRequired('巡更路线名称')],
  192. routePointRelationDtos: [this.$valid.inputRequired('巡更点')],
  193. startDate: [this.$valid.selectRequired('巡更日期')],
  194. timePeriod: [this.$valid.selectRequired('巡更时间')],
  195. periodValue: [this.$valid.selectRequired('巡更周期')]
  196. },
  197. effectiveDate: [],
  198. patrolArr: [],
  199. targetData: []
  200. };
  201. },
  202. watch: {
  203. 'ruleForm.communityId'(e) {
  204. this.getPoint(e);
  205. },
  206. periodValue(e) {
  207. this.ruleForm.periodValue = e.join();
  208. }
  209. },
  210. methods: {
  211. //保存
  212. addEdit() {
  213. this.$refs.ruleForm.validate(valid => {
  214. if (valid) {
  215. let url = '/sc-community/patrolRoute/add';
  216. this.ruleForm;
  217. let dotArr = arr => {
  218. let dotObj = [];
  219. arr.map((item, index) => {
  220. dotObj.push({
  221. pointId: item,
  222. order: index
  223. });
  224. });
  225. return dotObj;
  226. };
  227. let params = {
  228. communityId: this.ruleForm.communityId,
  229. routeName: this.ruleForm.routeName,
  230. routePointRelationDtos: dotArr(this.ruleForm.routePointRelationDtos),
  231. startDate: this.ruleForm.startDate,
  232. endDate: this.ruleForm.endDate,
  233. timePeriod: this.ruleForm.timePeriod,
  234. periodType: this.ruleForm.periodType,
  235. periodValue: this.ruleForm.periodValue,
  236. positioningDistance: this.ruleForm.positioningDistance,
  237. cameraSettings: this.ruleForm.cameraSettings,
  238. remark: this.ruleForm.remark
  239. };
  240. this.$http
  241. .post(url, params)
  242. .then(({ status, msg }) => {
  243. if (status == 0) {
  244. this.$message.success(msg);
  245. this.close();
  246. } else {
  247. this.$message.error(msg);
  248. }
  249. })
  250. .catch(() => {});
  251. }
  252. });
  253. },
  254. effectiveDateToggle(va) {
  255. let arr = va;
  256. if (!arr) {
  257. arr = ['', ''];
  258. }
  259. this.ruleForm.startDate = arr[0];
  260. this.ruleForm.endDate = arr[1];
  261. },
  262. close() {
  263. this.$emit('initPage');
  264. },
  265. getPoint(id) {
  266. this.$http.get('/sc-community/patrol/point/getPointList', { id, id }).then(({ data, status, msg }) => {
  267. this.patrolArr = data;
  268. });
  269. },
  270. handleChange() {
  271. this.$nextTick(() => {
  272. this.targetData = this.$refs.transferTude.targetData;
  273. });
  274. },
  275. addTime(inx, sun) {
  276. if (sun > 0) {
  277. this.timePeriod.push({ startTime: '', endTime: '' });
  278. } else {
  279. this.timePeriod.splice(inx, 1);
  280. }
  281. },
  282. timeChange(itm, str) {
  283. if (!!itm['endTime'] && !!itm['startTime']) {
  284. let TimeArr = [];
  285. this.timePeriod.map((item, index) => {
  286. TimeArr.push(`${item.startTime}-${item.endTime}`);
  287. });
  288. this.ruleForm.timePeriod = TimeArr.join();
  289. }
  290. }
  291. },
  292. created() {}
  293. };
  294. </script>
  295. <style lang='scss' scoped>
  296. @import '@assets/css/public-style.scss';
  297. .main {
  298. padding: 20px;
  299. background: white;
  300. .blockName {
  301. padding-bottom: 20px;
  302. margin-bottom: 20px;
  303. border-bottom: 1px solid #e0e1e3;
  304. }
  305. }
  306. .show-required-icon-star {
  307. &:before {
  308. content: '*';
  309. color: #f56c6c;
  310. }
  311. }
  312. .formContent {
  313. display: flex;
  314. justify-content: space-between;
  315. .formContent-item {
  316. width: 49%;
  317. }
  318. .periodValueInput {
  319. color: #606266;
  320. }
  321. .sunm {
  322. width: 15px;
  323. text-align: center;
  324. display: inline-block;
  325. cursor: pointer;
  326. margin-left: 10px;
  327. }
  328. .timeList {
  329. margin-bottom: 10px;
  330. &:nth-last-child() {
  331. margin: 0;
  332. }
  333. }
  334. }
  335. .width50 {
  336. width: calc(50% - 40px);
  337. & + span {
  338. margin: 0 3px;
  339. display: inline-block;
  340. }
  341. }
  342. </style>