addPatrol.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <div class="main">
  3. <div class="blockName">{{ disable == '1' ? '详情' : '新增' }}巡更路线( <span class="show-required-icon-star"></span>为必填项)</div>
  4. <el-form
  5. :model="ruleForm"
  6. :rules="rules"
  7. ref="ruleForm"
  8. label-width="120px"
  9. class="formContent"
  10. >
  11. <div class="formContent-item">
  12. <el-form-item
  13. label="所属社区"
  14. prop="communityId"
  15. >
  16. <el-select
  17. class="width100"
  18. v-model="ruleForm.communityId"
  19. placeholder="所属社区"
  20. clearable
  21. :disabled="disable == '1' ? true : false"
  22. >
  23. <el-option
  24. v-for="(item, index) in $parent.communityArr"
  25. :key="index"
  26. :label="item.communityName"
  27. :value="item.id"
  28. ></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item
  32. label="巡更路线名称"
  33. prop="routeName"
  34. >
  35. <el-input
  36. v-model="ruleForm.routeName"
  37. :disabled="disable == '1' ? true : false"
  38. placeholder="请输入巡更路线名称"
  39. ></el-input>
  40. </el-form-item>
  41. <el-form-item
  42. label="巡更点"
  43. prop="routePointRelationDtos"
  44. >
  45. <el-transfer
  46. v-model="ruleForm.routePointRelationDtos"
  47. ref="transferTude"
  48. filterable
  49. style="margin-bottom: 20px"
  50. :props="{
  51. key: 'id',
  52. label: 'pointName',
  53. lan: 'latitude',
  54. lng: 'longitude',
  55. }"
  56. :titles="['待选列表', '已选列表']"
  57. @change="handleChange"
  58. target-order="push"
  59. :data="patrolArr"
  60. >
  61. <div
  62. slot-scope="{ option }"
  63. class="transferTudeClass"
  64. >
  65. <span>{{ option.pointName }}</span>
  66. <div>
  67. <span
  68. class="zoniot_font zoniot-icon-shang"
  69. @click="optionUp(0, option)"
  70. ></span>
  71. <span
  72. class="zoniot_font zoniot-icon-xia"
  73. @click="optionUp(1, option)"
  74. ></span>
  75. </div>
  76. </div>
  77. </el-transfer>
  78. <map-value :point="targetData"></map-value>
  79. </el-form-item>
  80. </div>
  81. <div class="formContent-item">
  82. <el-form-item
  83. label="巡更日期"
  84. prop="startDate"
  85. >
  86. <el-date-picker
  87. class="width100"
  88. v-model="effectiveDate"
  89. value-format="yyyy-MM-dd"
  90. type="daterange"
  91. range-separator="至"
  92. start-placeholder="选择开始日期"
  93. end-placeholder="选择结束日期"
  94. @change="effectiveDateToggle"
  95. :editable="false"
  96. :disabled="disable == '1' ? true : false"
  97. ></el-date-picker>
  98. </el-form-item>
  99. <el-form-item
  100. label="巡更时间"
  101. prop="timePeriod"
  102. >
  103. <div
  104. class="timeList"
  105. v-for="(item, index) in timePeriod"
  106. :key="index"
  107. >
  108. <el-time-select
  109. class="width50"
  110. placeholder="开始时间"
  111. v-model="item.startTime"
  112. :picker-options="{
  113. start: '00:00',
  114. step: '00:15',
  115. end: '23:30'
  116. }"
  117. @change="timeChange(item, 'startTime')"
  118. :disabled="disable == '1' ? true : false"
  119. ></el-time-select>
  120. <span>至</span>
  121. <el-time-select
  122. placeholder="结束时间"
  123. v-model="item.endTime"
  124. class="width50"
  125. :picker-options="{
  126. start: '00:00',
  127. step: '00:15',
  128. end: '23:30',
  129. minTime: item.startTime
  130. }"
  131. @change="timeChange(item, 'endTime')"
  132. :disabled="disable == '1' ? true : false"
  133. ></el-time-select>
  134. <div
  135. class="sunm"
  136. @click="addTime(index, 1)"
  137. v-show="disable == '1' ? false : true"
  138. >
  139. <i class="zoniot_font zoniot-icon-tianjia1"></i>
  140. </div>
  141. <div
  142. class="sunm"
  143. @click="addTime(index, -1)"
  144. v-show="disable == '1' ? false : true"
  145. v-if="timePeriod.length > 1 && index != 0"
  146. >
  147. <i class="zoniot_font zoniot-icon-shanjian"></i>
  148. </div>
  149. </div>
  150. </el-form-item>
  151. <el-form-item
  152. label="巡更周期"
  153. prop="periodValue"
  154. >
  155. <el-radio-group
  156. v-model="ruleForm.periodType"
  157. :disabled="disable == '1' ? true : false"
  158. >
  159. <el-radio :label="1">每周重复</el-radio>
  160. <el-radio :label="2">间隔天数重复</el-radio>
  161. </el-radio-group>
  162. <el-checkbox-group
  163. v-if="ruleForm.periodType == 1"
  164. v-model="periodValue"
  165. :disabled="disable == '1' ? true : false"
  166. >
  167. <el-checkbox :label="1">周一</el-checkbox>
  168. <el-checkbox :label="2">周二</el-checkbox>
  169. <el-checkbox :label="3">周三</el-checkbox>
  170. <el-checkbox :label="4">周四</el-checkbox>
  171. <el-checkbox :label="5">周五</el-checkbox>
  172. <el-checkbox :label="6">周六</el-checkbox>
  173. <el-checkbox :label="7">周日</el-checkbox>
  174. </el-checkbox-group>
  175. <div
  176. v-else
  177. class="periodValueInput"
  178. >
  179. 每隔
  180. <el-input-number
  181. v-model="ruleForm.periodValue"
  182. controls-position="right"
  183. :min="0"
  184. :max="30"
  185. :disabled="disable == '1' ? true : false"
  186. ></el-input-number>天进行(输入0-30的数字,0代表每天都要进行任务)
  187. </div>
  188. </el-form-item>
  189. <el-form-item label="定位距离(m)">
  190. <el-input
  191. v-model="ruleForm.positioningDistance"
  192. :disabled="disable == '1' ? true : false"
  193. placeholder="巡更定位距离,可输入1-100米,不输入则不检查定位距离"
  194. ></el-input>
  195. </el-form-item>
  196. <el-form-item label="拍照/视频要求">
  197. <el-select
  198. class="width100"
  199. v-model="ruleForm.cameraSettings"
  200. placeholder="请选择拍照/视频要求"
  201. clearable
  202. :disabled="disable == '1' ? true : false"
  203. >
  204. <el-option
  205. label="是"
  206. :value="1"
  207. ></el-option>
  208. <el-option
  209. label="否"
  210. :value="0"
  211. ></el-option>
  212. </el-select>
  213. </el-form-item>
  214. <el-form-item
  215. label="按巡更点顺序签到"
  216. label-width="130"
  217. >
  218. <el-radio-group
  219. v-model="ruleForm.signFlag"
  220. :disabled="disable == '1' ? true : false"
  221. >
  222. <el-radio :label="1">是</el-radio>
  223. <el-radio :label="0">否</el-radio>
  224. </el-radio-group>
  225. </el-form-item>
  226. <el-form-item label="备注信息">
  227. <el-input
  228. type="textarea"
  229. placeholder="请输入备注信息"
  230. resize="none"
  231. :rows="4"
  232. v-model="ruleForm.remark"
  233. maxlength="300"
  234. show-word-limit
  235. :disabled="disable == '1' ? true : false"
  236. ></el-input>
  237. </el-form-item>
  238. </div>
  239. </el-form>
  240. <div
  241. style="text-align: right"
  242. v-if="disable == '1' ? false : true"
  243. >
  244. <el-button @click="close">取消</el-button>
  245. <el-button
  246. type="primary"
  247. @click="addEdit"
  248. >保存</el-button>
  249. </div>
  250. <div
  251. style="text-align: right"
  252. v-if="disable == '1' ? true : false"
  253. >
  254. <el-button
  255. @click="close"
  256. style="width: 120px;"
  257. >返回</el-button>
  258. </div>
  259. </div>
  260. </template>
  261. <script>
  262. import mapValue from './mapValue.vue';
  263. export default {
  264. props: ['patrolDetail', 'disable'],
  265. components: { mapValue },
  266. data () {
  267. return {
  268. disables: false,
  269. ruleForm: {
  270. communityId: '',
  271. routeName: '',
  272. routePointRelationDtos: [],
  273. startDate: '',
  274. endDate: '',
  275. timePeriod: '',
  276. periodType: 1,
  277. periodValue: '',
  278. positioningDistance: '',
  279. cameraSettings: '',
  280. signFlag: 1,
  281. remark: ''
  282. },
  283. periodValue: [],
  284. timePeriod: [
  285. {
  286. startTime: '',
  287. endTime: ''
  288. }
  289. ],
  290. rules: {
  291. communityId: [this.$valid.inputRequired('社区名称')],
  292. routeName: [this.$valid.inputRequired('巡更路线名称')],
  293. routePointRelationDtos: [this.$valid.selectRequired('巡更点')],
  294. startDate: [this.$valid.selectRequired('巡更日期')],
  295. timePeriod: [this.$valid.selectRequired('巡更时间')],
  296. periodValue: [this.$valid.selectRequired('巡更周期')]
  297. },
  298. effectiveDate: [],
  299. patrolArr: [],
  300. targetData: []
  301. };
  302. },
  303. watch: {
  304. 'ruleForm.communityId' (e) {
  305. this.getPoint(e);
  306. },
  307. periodValue (e) {
  308. this.ruleForm.periodValue = e.join();
  309. }
  310. },
  311. methods: {
  312. disabledDate () {
  313. debugger
  314. alert(1)
  315. },
  316. //保存
  317. addEdit () {
  318. this.$refs.ruleForm.validate((valid) => {
  319. if (valid) {
  320. let url = '/czc-community/patrolRoute/add';
  321. this.ruleForm;
  322. let dotArr = (arr) => {
  323. let dotObj = [];
  324. arr.map((item, index) => {
  325. dotObj.push({
  326. pointId: item,
  327. order: index
  328. });
  329. });
  330. return dotObj;
  331. };
  332. let params = {
  333. communityId: this.ruleForm.communityId,
  334. routeName: this.ruleForm.routeName,
  335. routePointRelationDtos: dotArr(this.ruleForm.routePointRelationDtos),
  336. startDate: this.ruleForm.startDate,
  337. endDate: this.ruleForm.endDate,
  338. timePeriod: this.ruleForm.timePeriod,
  339. periodType: this.ruleForm.periodType,
  340. periodValue: this.ruleForm.periodValue,
  341. positioningDistance: this.ruleForm.positioningDistance,
  342. cameraSettings: this.ruleForm.cameraSettings,
  343. signFlag: this.ruleForm.signFlag,
  344. remark: this.ruleForm.remark
  345. };
  346. this.$http
  347. .post(url, params)
  348. .then(({ status, msg }) => {
  349. if (status == 0) {
  350. this.$message.success(msg);
  351. this.close();
  352. } else {
  353. this.$message.error(msg);
  354. }
  355. })
  356. .catch(() => { });
  357. }
  358. });
  359. },
  360. effectiveDateToggle (va) {
  361. let arr = va;
  362. if (!arr) {
  363. arr = ['', ''];
  364. }
  365. this.ruleForm.startDate = arr[0];
  366. this.ruleForm.endDate = arr[1];
  367. },
  368. close () {
  369. this.$emit('initPage');
  370. },
  371. getPoint (id) {
  372. if (JSON.stringify(this.patrolDetail) == "{}") {
  373. this.ruleForm.routePointRelationDtos = [];
  374. this.targetData = [];
  375. this.$http.get('/czc-community/patrol/point/getPointList', { id, id }).then(({ data, status, msg }) => {
  376. this.patrolArr = data;
  377. });
  378. } else {
  379. this.$http.get('/czc-community/patrol/point/getPointList', { id, id }).then(({ data, status, msg }) => {
  380. this.patrolArr = data;
  381. for (let i = 0; i < this.patrolArr.length; i++) {
  382. this.patrolArr[i]['disabled'] = true;
  383. }
  384. console.log(this.patrolArr)
  385. this.handleChange();
  386. });
  387. }
  388. },
  389. handleChange () {
  390. this.$nextTick(() => {
  391. this.targetData = this.$refs.transferTude.targetData;
  392. });
  393. },
  394. addTime (inx, sun) {
  395. if (sun > 0) {
  396. this.timePeriod.push({ startTime: '', endTime: '' });
  397. } else {
  398. this.timePeriod.splice(inx, 1);
  399. }
  400. },
  401. timeChange (itm, str) {
  402. if (!!itm['endTime'] && !!itm['startTime']) {
  403. let TimeArr = [];
  404. this.timePeriod.map((item, index) => {
  405. TimeArr.push(`${item.startTime}-${item.endTime}`);
  406. });
  407. this.ruleForm.timePeriod = TimeArr.join();
  408. }
  409. },
  410. optionUp (nub, item) {
  411. if (this.disable != '1') {
  412. let thisArr = this.ruleForm.routePointRelationDtos;
  413. let okArr = this.$refs.transferTude.targetData;
  414. let newArr = [];
  415. let inx = null;
  416. thisArr.map((list, index) => {
  417. if (list == item.id) {
  418. inx = index;
  419. }
  420. return inx;
  421. });
  422. if (inx !== null && thisArr.length > 1) {
  423. //向下
  424. if (nub == 1 && inx < thisArr.length - 1) {
  425. thisArr.splice(inx + 1, 1, ...thisArr.splice(inx, 1, thisArr[inx + 1]));
  426. okArr.splice(inx + 1, 1, ...okArr.splice(inx, 1, okArr[inx + 1]));
  427. } else if (nub != 1 && inx > 0) {
  428. thisArr.splice(inx, 1, ...thisArr.splice(inx - 1, 1, thisArr[inx]));
  429. okArr.splice(inx, 1, ...okArr.splice(inx - 1, 1, okArr[inx]));
  430. }
  431. this.targetData = okArr;
  432. }
  433. }
  434. },
  435. // /czc-community/patrol/point/list/point
  436. patrolPoint () {
  437. this.$http.get('/czc-community/patrol/point/list/point', { routeId: this.patrolDetail.id }).then(({ data, status, msg }) => {
  438. // debugger
  439. if (status == 0) {
  440. // this.ruleForm.routePointRelationDtos
  441. this.ruleForm.routePointRelationDtos = [];
  442. data.map((item, index) => {
  443. this.ruleForm.routePointRelationDtos.push(item.pointId)
  444. })
  445. console.log('this.ruleForm.routePointRelationDtos', this.ruleForm.routePointRelationDtos);
  446. }
  447. })
  448. }
  449. },
  450. created () {
  451. if (JSON.stringify(this.patrolDetail) == "{}") {
  452. return;
  453. } else {
  454. this.ruleForm.communityId = this.patrolDetail.communityId;
  455. this.ruleForm.routeName = this.patrolDetail.routeName;
  456. this.effectiveDate[0] = this.patrolDetail.startDate;
  457. this.effectiveDate[1] = this.patrolDetail.endDate;
  458. this.timePeriod = [];
  459. let dataRes = this.patrolDetail.timePeriod.split(",");
  460. dataRes.map((item, index) => {
  461. this.timePeriod.push({
  462. startTime: (item).substr(0, 5),
  463. endTime: (item).substr(6, 5),
  464. })
  465. });
  466. this.ruleForm.periodType = this.patrolDetail.periodType;
  467. let data = [];
  468. this.periodValue = [];
  469. data = (this.patrolDetail.periodValue).split(",");
  470. data.map((item) => {
  471. this.periodValue.push(Number(item))
  472. });
  473. this.ruleForm.positioningDistance = this.patrolDetail.positioningDistance;
  474. this.ruleForm.cameraSettings = this.patrolDetail.cameraSettings;
  475. this.ruleForm.signFlag = this.patrolDetail.signFlag;
  476. this.ruleForm.remark = this.patrolDetail.remark;
  477. this.patrolPoint();
  478. }
  479. }
  480. };
  481. </script>
  482. <style lang='scss' scoped>
  483. @import '@assets/css/public-style.scss';
  484. .main {
  485. padding: 20px;
  486. background: white;
  487. .blockName {
  488. padding-bottom: 20px;
  489. margin-bottom: 20px;
  490. border-bottom: 1px solid #e0e1e3;
  491. }
  492. }
  493. .show-required-icon-star {
  494. &:before {
  495. content: '*';
  496. color: #f56c6c;
  497. }
  498. }
  499. .formContent {
  500. display: flex;
  501. justify-content: space-between;
  502. .formContent-item {
  503. width: 49%;
  504. }
  505. .periodValueInput {
  506. color: #606266;
  507. }
  508. .sunm {
  509. width: 15px;
  510. text-align: center;
  511. display: inline-block;
  512. cursor: pointer;
  513. margin-left: 10px;
  514. }
  515. .timeList {
  516. margin-bottom: 10px;
  517. &:nth-last-child() {
  518. margin: 0;
  519. }
  520. }
  521. }
  522. .width50 {
  523. width: calc(50% - 40px);
  524. & + span {
  525. margin: 0 3px;
  526. display: inline-block;
  527. }
  528. }
  529. /deep/ .el-transfer-panel__item.el-checkbox {
  530. margin-right: 0;
  531. }
  532. .transferTudeClass {
  533. display: flex;
  534. justify-content: space-between;
  535. > div {
  536. width: 60px;
  537. display: flex;
  538. justify-content: space-around;
  539. }
  540. .zoniot_font {
  541. line-height: 30px;
  542. }
  543. }
  544. /deep/ .el-transfer-panel:first-child {
  545. .transferTudeClass {
  546. > div {
  547. display: none;
  548. }
  549. }
  550. }
  551. </style>