addPatrol.vue 13 KB

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