addInfo.vue 13 KB

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