addInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <div>
  3. <NavBar />
  4. <div :class="disabled? 'bigBoxInfo':'bigBox'">
  5. <van-row>
  6. <van-col span="24">
  7. <!-- <van-cell title="任务名称" value="每周监控调阅(0501~0507)" /> -->
  8. <div class="textTitle">任务名称:{{ taskData?.taskName }}</div>
  9. </van-col>
  10. <van-col span="24">
  11. <!-- <van-cell title="调阅开始时间" value="2023-05-05 10:12" /> -->
  12. <div class="text">调阅开始时间:{{ taskData?.taskStartTime }}</div>
  13. </van-col>
  14. </van-row>
  15. <!-- 主机选择 -->
  16. <van-row>
  17. <van-col span="24">
  18. <van-field
  19. required
  20. v-model="host"
  21. is-link
  22. readonly
  23. label="监控主机"
  24. placeholder=""
  25. :disabled="disabled"
  26. @click="showHost = true"
  27. />
  28. <van-popup v-model="showHost" round position="bottom">
  29. <van-picker
  30. title="监控主机"
  31. show-toolbar
  32. :columns="hostList"
  33. @confirm="onConfirm"
  34. @cancel="showHost = false"
  35. @change="onChange"
  36. >
  37. <template #option="option">
  38. <div style="display: flex; flex-direction: column; align-items: center">
  39. <div>{{ option.deviceName }}</div>
  40. </div>
  41. </template>
  42. </van-picker>
  43. </van-popup></van-col
  44. >
  45. </van-row>
  46. <!-- 视频通道 -->
  47. <van-row>
  48. <van-col span="24">
  49. <van-field
  50. required
  51. v-model="fieldValue"
  52. :disabled="disabled || ishost"
  53. is-link
  54. readonly
  55. label="视频通道"
  56. placeholder=""
  57. @click="showStatus = true"
  58. />
  59. <van-popup v-model="showStatus" :disabled="ishost" round position="bottom">
  60. <van-picker
  61. title="视频通道"
  62. show-toolbar
  63. :columns="columns"
  64. @confirm="onConfirmPassage"
  65. @cancel="showStatus = false"
  66. @change="onChange"
  67. >
  68. <template #option="option">
  69. <div style="display: flex; flex-direction: column; align-items: center">
  70. <div>{{ option.deviceName }}</div>
  71. </div>
  72. </template>
  73. </van-picker>
  74. </van-popup></van-col
  75. >
  76. </van-row>
  77. <van-row>
  78. <van-col span="24" v-if="!disabled">
  79. <van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
  80. 请选择实际调阅项目进行填写,不需要编辑所有项目
  81. </van-notice-bar>
  82. </van-col>
  83. </van-row>
  84. <div>
  85. <van-form ref="vform">
  86. <!-- 主体选择项 -->
  87. <van-collapse v-model="activeNames" :is-link="false">
  88. <van-collapse-item :name="item.dictValue" v-for="item in dataList" :key="item.dictValue">
  89. <template #title>
  90. <div>
  91. <van-checkbox :disabled="disabled" v-model="item.isChecked" shape="square">{{
  92. item.dictLabel
  93. }}</van-checkbox>
  94. </div>
  95. </template>
  96. <van-row>
  97. <van-col span="24">
  98. <van-dropdown-menu>
  99. <van-dropdown-item
  100. :disabled ="disabled"
  101. v-model="item.situation"
  102. @change="changeHandler($event, item)"
  103. :options="dictList"
  104. />
  105. </van-dropdown-menu>
  106. </van-col>
  107. </van-row>
  108. <van-form>
  109. <van-row v-show="item.situation == '1'">
  110. <van-col span="24">
  111. <van-field
  112. v-model="item.abnormalIllustrate"
  113. rows="2"
  114. autosize
  115. :disabled="disabled"
  116. required
  117. :maxlength="50"
  118. label="异常说明"
  119. type="textarea"
  120. placeholder="请输入异常说明"
  121. show-word-limit
  122. :rules="[{ required: true, message: '内容不能为空' }]"
  123. />
  124. </van-col>
  125. </van-row>
  126. </van-form>
  127. </van-collapse-item>
  128. </van-collapse>
  129. </van-form>
  130. </div>
  131. <!-- 底部按钮 -->
  132. <div class="bottomClass" >
  133. <van-row>
  134. <van-col span="24">
  135. <van-button type="info" v-if="!disabled" @click="addForm">{{
  136. $route.params.id.split('_')[2] == 'edit' ? '修改' : '添加'
  137. }}</van-button>
  138. </van-col>
  139. </van-row>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import NavBar from '@/components/NavBar'
  146. // 主机列表组件
  147. import MonitoingList from './monitoringList.vue'
  148. import { Col, Row, Dialog, Icon, Toast, Picker } from 'vant'
  149. import {
  150. registrationList,
  151. addInfo,
  152. updateInfo,
  153. getEditInfo,
  154. getSysDeviceByHostId,
  155. getorgHost
  156. } from '@/api/toConsult.js'
  157. import { mapGetters } from 'vuex'
  158. export default {
  159. data() {
  160. return {
  161. disabled: '', //是否禁用
  162. taskId: '', //任务ID
  163. falg: false, //校验是否通过
  164. dictList: [], //异常正常字典
  165. columns: [], //通道列表
  166. hostList: [], //主机列表
  167. showStatus: false, //通道显示隐藏
  168. showHost: false, //主机显示隐藏
  169. checked: false,
  170. checked1: false,
  171. message: '',
  172. ishost: true,
  173. fieldValue: '',
  174. host: '', //主机名称
  175. hostId: '', //主机ID
  176. videoChannel: '', //通道ID
  177. value1: 0,
  178. dicts: ['core_registration_project'],
  179. option1: [
  180. { text: '异常', value: 0 },
  181. { text: '正常', value: 1 }
  182. ],
  183. activeNames: [''],
  184. dataList: [], //列表
  185. taskData: []
  186. }
  187. },
  188. components: {
  189. NavBar,
  190. Dialog,
  191. Icon,
  192. Picker,
  193. Col,
  194. Row,
  195. MonitoingList
  196. },
  197. computed: {
  198. monitor() {
  199. return 'monitor'
  200. },
  201. ...mapGetters(['orgName', 'orgId'])
  202. },
  203. created() {
  204. this.init()
  205. this.disabled = +this.$route.params.id.split('_')[3] ? true : false
  206. console.log(this.disabled)
  207. },
  208. mounted() {},
  209. methods: {
  210. //根据卡片ID获取详情数据
  211. getInfoHandler() {
  212. console.log(this.dataList);
  213. //判断当前路由的信息是新增还是编辑
  214. if ((this.$route.params.id.split('_')[2] == 'edit') && this.dataList.length > 0) {
  215. //当前是编辑
  216. //获取卡片详情数据
  217. getEditInfo(this.$route.params.id.split('_')[1]).then(res => {
  218. let { data, msg, code } = res
  219. if (code == 200) {
  220. ;(this.activeNames = ['']), //滞空选中
  221. this.dataList.forEach(item => {
  222. data.coreMonitoringTaskMonitorInfoList.forEach(i => {
  223. if (i.project == item.dictValue) {
  224. //查询赋值
  225. this.$set(item, 'isChecked', true)
  226. this.$set(item, 'situation', i.situation)
  227. this.$set(item, 'abnormalIllustrate', i.abnormalIllustrate)
  228. this.activeNames.push(i.project)
  229. }
  230. })
  231. })
  232. //赋值主机&通道名称
  233. this.host = data.hostName
  234. this.hostId = data.host
  235. this.fieldValue = data.videoChannelName
  236. this.videoChannel = data.videoChannel
  237. console.log(this.hostId)
  238. this.getHostTDlist(this.hostId)
  239. }
  240. })
  241. }
  242. },
  243. //项目初始化获取数据
  244. init() {
  245. //获取组织机构数据
  246. registrationList({ taskId: this.$route.params.id.split('_')[0] }).then(res => {
  247. let { code, data, msg } = res
  248. if (code == 200) {
  249. this.taskData = data
  250. }
  251. })
  252. //获取当前登录人机构下主机列表
  253. getorgHost({ orgId: this.orgId, monitorId: this.$route.params.id.split('_')[1] }).then(res => {
  254. let { code, data, msg } = res
  255. if (code == 200) {
  256. this.hostList = data
  257. }
  258. })
  259. this.getDictHandler('core_registration_project', res => {
  260. this.dataList = JSON.parse(JSON.stringify(res))
  261. this.dataList.forEach(item => {
  262. this.$set(item, 'situation', '0') //异常情况初始化默认值
  263. this.$set(item, 'abnormalIllustrate', '') //情况说明初始化默认值
  264. })
  265. this.getInfoHandler() //获取详情
  266. })
  267. //获取异常情况字典
  268. this.getDictHandler('core_check_type', res => {
  269. this.dictList = res
  270. this.dictList.forEach(item => {
  271. item.text = item.dictLabel
  272. item.value = item.dictValue
  273. })
  274. })
  275. },
  276. onConfirm(value, index) {
  277. this.host = this.hostList[index].deviceName
  278. this.hostId = this.hostList[index].id
  279. this.getHostTDlist(this.hostId)
  280. },
  281. //通过主机ID获取通道列表
  282. getHostTDlist(id) {
  283. //通过主机ID获取通道列表
  284. getSysDeviceByHostId({ hostId: id, monitorId: this.$route.params.id.split('_')[1] }).then(res => {
  285. let { code, data, msg } = res
  286. if (code == 200) {
  287. this.columns = data
  288. console.log(data)
  289. this.ishost = false
  290. this.showHost = false
  291. }
  292. })
  293. },
  294. onConfirmPassage(value, index) {
  295. this.fieldValue = this.columns[index].deviceName
  296. this.videoChannel = this.columns[index].id
  297. this.showStatus = false
  298. },
  299. onChange(picker, value, index) {},
  300. onFailed(errorInfo) {
  301. this.falg = true
  302. },
  303. changeHandler(val, item) {
  304. if (val == '0') {
  305. item.abnormalIllustrate = ''
  306. }
  307. },
  308. onCancel() {
  309. Toast('取消')
  310. },
  311. //表单提交前校验
  312. beforSubmitV() {
  313. this.falg = false
  314. if (this.host == '' && this.hostId == '') {
  315. Toast('监控主机不能为空!')
  316. this.falg = true
  317. return
  318. }
  319. if (this.fieldValue == '' && this.videoChannel == '') {
  320. Toast('视频通道不能为空!')
  321. this.falg = true
  322. return
  323. }
  324. console.log(this.dataList)
  325. this.dataList.forEach(item => {
  326. if (item.situation == '1' && item.abnormalIllustrate == '') {
  327. Toast(`${item.dictLabel}的异常情况说明不能为空!`)
  328. this.falg = true
  329. }
  330. })
  331. },
  332. //表单提交
  333. addForm() {
  334. this.beforSubmitV()
  335. if (this.falg) {
  336. //校验不通过
  337. } else {
  338. let list = []
  339. this.activeNames.forEach(item => {
  340. this.dataList.forEach(i => {
  341. if (item == i.dictValue) {
  342. i.project = i.dictValue
  343. list.push(i)
  344. }
  345. })
  346. })
  347. if (this.$route.params.id.split('_')[2] == 'edit') {
  348. //编辑提交
  349. updateInfo({
  350. host: this.hostId,
  351. // taskRegistrationId:+this.$route.params.id.split('_')[1],
  352. videoChannel: this.videoChannel,
  353. id: this.$route.params.id.split('_')[1],
  354. coreMonitoringTaskMonitorInfoList: list
  355. }).then(res => {
  356. let { data, msg, code } = res
  357. if (code == 200) {
  358. Toast('编辑成功!')
  359. this.$router.push('/consultInfo/' + this.$route.params.id.split('_')[0])
  360. }
  361. this.falg = false
  362. })
  363. } else {
  364. //新增提交
  365. addInfo({
  366. host: this.hostId,
  367. // taskRegistrationId:+this.$route.params.id.split('_')[1],
  368. videoChannel: this.videoChannel,
  369. taskRegistrationId: this.$route.params.id.split('_')[1],
  370. coreMonitoringTaskMonitorInfoList: list
  371. }).then(res => {
  372. let { data, msg, code } = res
  373. if (code == 200) {
  374. Toast('添加成功!')
  375. this.$router.push('/consultInfo/' + this.$route.params.id.split('_')[0])
  376. }
  377. this.falg = false
  378. })
  379. }
  380. }
  381. }
  382. }
  383. }
  384. </script>
  385. <style lang="scss" scoped>
  386. .bigBox {
  387. height: calc(100vh - 260px);
  388. overflow: scroll;
  389. }
  390. .bigBoxInfo {
  391. height: calc(100vh);
  392. overflow: scroll;
  393. }
  394. .van-button {
  395. width: 100%;
  396. margin-top: 10px;
  397. border-radius: 10px;
  398. }
  399. .bottomClass {
  400. position: fixed;
  401. width: 100%;
  402. bottom: 0%;
  403. }
  404. .condition {
  405. font-size: 50px !important;
  406. line-height: 50px;
  407. color: #1989fa;
  408. }
  409. .textTitle {
  410. font-size: 40px;
  411. font-weight: bold;
  412. padding: 20px;
  413. }
  414. .text {
  415. padding: 20px;
  416. font-size: 26px;
  417. }
  418. </style>