jcobj.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <div style="width: 100%">
  3. <el-card class="box-card">
  4. <div slot="header" class="clearfix">
  5. <el-breadcrumb separator-class="el-icon-arrow-right">
  6. <el-breadcrumb-item>首页</el-breadcrumb-item>
  7. <el-breadcrumb-item>监测模型</el-breadcrumb-item>
  8. <el-breadcrumb-item>模型配置</el-breadcrumb-item>
  9. </el-breadcrumb>
  10. </div>
  11. <!-- 头部搜索栏 -->
  12. <el-row :gutter="50" style="margin-right: 0px;">
  13. <el-form style="display: flex; flex-direction: row;" size="mini">
  14. <el-form-item label="行业" class="select">
  15. <el-select v-model="queryInfo.type_id" clearable>
  16. <el-option v-for="item in field" :key="item.value" :label="item.label" :value="item.value">
  17. </el-option>
  18. </el-select>
  19. </el-form-item>
  20. <!-- 查询 -->
  21. <el-button style="height: 28px;margin-left: 10px;" type="success" size="mini" @click="searchData()">查询</el-button>
  22. <!-- 重置 -->
  23. <el-button style="height: 28px;margin-left: 5px;" type="success" size="mini" @click="reset()">重置</el-button>
  24. </el-form>
  25. </el-row>
  26. <!-- 头部钮区域-->
  27. <el-row :gutter="90" style="margin-right: 0px;">
  28. <div style="display: flex;flex-direction: row;float: right;">
  29. <el-button type="primary" size="small" plain icon="el-icon-plus" @click="add()">新增</el-button>
  30. <el-button type="primary" size="small" plain icon="el-icon-delete" @click="delmodel()">删除</el-button>
  31. </div>
  32. </el-row>
  33. <!-- 表格数据区域-->
  34. <el-table ref="multipleModelTable" :data="tableData" border stripe highlight-current-row style="width: 100%"
  35. :row-style="rowStyle" :cell-style="cellStyle" @selection-change="handleSelectionChange">
  36. <el-table-column type="selection" width="50" align="center"></el-table-column>
  37. <el-table-column label="序号" width="50px" align="center">
  38. <template slot-scope="scope">
  39. {{ scope.$index+1 }}
  40. </template>
  41. </el-table-column>
  42. <el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label" :prop="table.prop"
  43. align="center" :width="table.width" :fixed="table.fixed" />
  44. <el-table-column label="操作" align="center" fixed="right">
  45. <!-- 操作按钮区域的作用域插槽 -->
  46. <template slot-scope="scope">
  47. <el-button style="margin: 5px auto;" type="success" size="small" @click="getmodelDetail(scope.row.id)">配置模型</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  52. :current-page="queryInfo.pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="queryInfo.pageSize"
  53. layout="total, sizes, prev, pager, next, jumper" :total="total">
  54. </el-pagination>
  55. <!-- 配置模型对话框-->
  56. <el-dialog title="查看" :visible.sync="readDialogVisible" width="30%" :close-on-click-modal="false"
  57. class="dialogItem">
  58. <el-form v-if="readDialogVisible" :model="modelForm" label-width="100px">
  59. <el-form-item label="模型名称:" prop="name" class="labelItem">
  60. <el-input v-model="modelForm.name"></el-input>
  61. </el-form-item>
  62. <el-form-item label="适用行业:" prop="modelForm.type_id" class="labelItem">
  63. <el-select v-model="modelForm.type_id">
  64. <el-option v-for="item in field" :key="item.value" :label="item.label" :value="item.value">
  65. </el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item label="检测对象:" prop="productText" width="70px" class="labelItem">
  69. <el-input type="textarea" v-model="productText" autosize @focus="choseMonitoringTargetShow = true"></el-input>
  70. </el-form-item>
  71. <el-form-item label="检测项:" prop="pesticidesText" class="labelItem">
  72. <el-input v-model="pesticidesText" type="textarea" autosize @focus="choseProbePacketsShow = true" ></el-input>
  73. </el-form-item>
  74. <div class="footer">
  75. <el-button @click="readDialogVisible = false">取 消</el-button>
  76. <el-button type="primary" @click="onSubmit(modelForm.id)">提 交</el-button>
  77. </div>
  78. </el-form>
  79. <!-- 修改检测对象 -->
  80. <el-dialog title="修改检测对象" :visible.sync="choseMonitoringTargetShow" width="30%" :close-on-click-modal="false"
  81. @open="choseMonitoringTarget()" class="dialogItem" append-to-body>
  82. <el-input style="width: 200px;" placeholder="请选择检测对象" v-model="monitorText" clearable>
  83. </el-input>
  84. <el-tree node-key="id" class="filter-tree" ref="tree" :check-strictly="true" :data="monitoringTargetList" show-checkbox
  85. :props="defaultProps" :filter-node-method="filterNode" @check="currentChecked">
  86. </el-tree>
  87. <div class="footer">
  88. <el-button type="success" size="small" @click="choseMonitor(id)">确定</el-button>
  89. </div>
  90. </el-dialog>
  91. <!-- 修改检测项 -->
  92. <el-dialog title="修改检测项" :visible.sync="choseProbePacketsShow" width="40%" :close-on-click-modal="false"
  93. @open="choseProbePackets()" class="dialogItem" append-to-body>
  94. <el-input style="width: 200px;" placeholder="请选择检测包" v-model="queryInfo1.keyword" @input="searchData1()"
  95. clearable>
  96. </el-input>
  97. <!-- 表格数据区域-->
  98. <el-table ref="multipleTable" :data="pesticidesList" row-key="id" @selection-change="handleSelectionChange"
  99. border stripe highlight-current-row style="width: 100%">
  100. <el-table-column type="selection" :reserve-selection="true" width="50" align="center"></el-table-column>
  101. <el-table-column label="序号" width="50px" align="center">
  102. <template slot-scope="scope">
  103. {{ scope.$index+1 }}
  104. </template>
  105. </el-table-column>
  106. <!-- <el-table-column :key="table.prop" v-for="table in tableHeader" :label="table.label"
  107. :prop="table.prop" align="center" :width="table.width" :fixed="table.fixed" /> -->
  108. <el-table-column label="检测项目">
  109. <template slot-scope="scope">
  110. <span style="margin-left: 10px">{{ scope.row.name }}({{ scope.row.enname }})</span>
  111. <!-- <span style="margin-left: 10px">{{ scope.row.eaname }}</span> -->
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="检测标准" width="130px" align="center">
  115. <!-- <template slot-scope="scope">
  116. GB2763-2021
  117. </template> -->
  118. </el-table-column>
  119. </el-table>
  120. <div class="footer">
  121. <!-- 分页器区域-->
  122. <el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
  123. :current-page="queryInfo1.pageNum" :page-sizes="[10, 15, 20]" :page-size="queryInfo1.pageSize"
  124. layout="total, sizes, prev, pager, next, jumper" :total="total1" background />
  125. <el-button type="success" size="small" @click="choseProbe()">提交</el-button>
  126. </div>
  127. </el-dialog>
  128. </el-dialog>
  129. </el-card>
  130. </div>
  131. </template>
  132. <script>
  133. export default {
  134. name: '',
  135. data() {
  136. return {
  137. currentPage: 1,
  138. total: 0,
  139. total1:0,
  140. readDialogVisible: false,
  141. modelForm: {
  142. id:'',
  143. name: '',
  144. type_id: '',
  145. pesticides:[],
  146. product:[]
  147. },
  148. // 存检测项和检测对象字符串
  149. productText:'',
  150. pesticidesText:'',
  151. pesticides:[],
  152. product:[],
  153. cellStyle: {
  154. padding: 2 + 'px'
  155. },
  156. rowStyle: {
  157. height: 35 + 'px'
  158. },
  159. field: [{
  160. value: 1,
  161. label: '种植业'
  162. }, {
  163. value: 2,
  164. label: '畜牧业'
  165. }, {
  166. value: 3,
  167. label: '渔业'
  168. }, {
  169. value: 4,
  170. label: '其他'
  171. }],
  172. // 选择检测对象对话框
  173. choseMonitoringTargetShow: false,
  174. defaultProps: {
  175. label: 'name',
  176. children: 'children'
  177. },
  178. count: 1,
  179. monitoringTargetList: [],
  180. monitorText: '',
  181. // 选择检测包对话框
  182. choseProbePacketsShow: false,
  183. queryInfo1: {
  184. pageNum: 1,
  185. pageSize: 10,
  186. keyword: ''
  187. },
  188. // 检测包表格数据
  189. pesticidesList: [],
  190. multipleSelection: null,
  191. pesticides:[],
  192. tableHeader: [{
  193. label: '模型名称',
  194. prop: 'name',
  195. // fixed: 'left'
  196. },
  197. {
  198. label: '行业',
  199. prop: 'type',
  200. // fixed: 'left'
  201. },
  202. {
  203. label: '创建时间',
  204. prop: 'creattime',
  205. },
  206. ],
  207. // 数据表格数据
  208. tableData: [],
  209. delarry:[],
  210. // 批量删除选中数据
  211. multipleSelection1: null,
  212. queryInfo: {
  213. pageSize:10,
  214. pageNum:1,
  215. type_id:""
  216. },
  217. // 任务状态选项
  218. taskstatus: [{
  219. value: '选项1',
  220. label: '全部'
  221. }, {
  222. value: '选项2',
  223. label: '未发布'
  224. }, {
  225. value: '选项3',
  226. label: '已发布'
  227. }, {
  228. value: '选项4',
  229. label: '已废止'
  230. }, {
  231. value: '选项5',
  232. label: '执行中'
  233. }, {
  234. value: '选项6',
  235. label: '已结束,未完成'
  236. }, {
  237. value: '选项7',
  238. label: '已结束,已完成'
  239. }],
  240. // 日期选择器快捷选项
  241. pickerOptions: {
  242. disabledDate(time) {
  243. return time.getTime() > Date.now();
  244. },
  245. shortcuts: [{
  246. text: '今天',
  247. onClick(picker) {
  248. picker.$emit('pick', new Date());
  249. }
  250. }, {
  251. text: '昨天',
  252. onClick(picker) {
  253. const date = new Date();
  254. date.setTime(date.getTime() - 3600 * 1000 * 24);
  255. picker.$emit('pick', date);
  256. }
  257. }, {
  258. text: '一周前',
  259. onClick(picker) {
  260. const date = new Date();
  261. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  262. picker.$emit('pick', date);
  263. }
  264. }]
  265. },
  266. }
  267. },
  268. mounted: function() {
  269. // this.getmodelList()
  270. },
  271. created(){
  272. this.getmodelList()
  273. },
  274. watch: {
  275. monitorText(val) {
  276. this.$refs.tree.filter(val);
  277. }
  278. },
  279. methods: {
  280. handleSizeChange(val) {
  281. this.queryInfo.pageSize = val;
  282. console.log(`每页 ${val} 条`);
  283. },
  284. handleCurrentChange(val) {
  285. this.queryInfo.pageNum = val;
  286. console.log(`当前页: ${val}`);
  287. this.getmodelList()
  288. },
  289. // 新增模型
  290. add() {
  291. this.$router.push({
  292. path: '/jc/modelSet',
  293. })
  294. },
  295. async delmodel(){
  296. console.log(this.multipleSelection)
  297. var that = this;
  298. const length = this.multipleSelection.length;
  299. console.log(length)
  300. console.log(this.multipleSelection)
  301. for (let i = 0; i < length; i++) {
  302. console.log(this.multipleSelection[i])
  303. this.delarry.push(this.multipleSelection[i]);
  304. }
  305. console.log(this.multipleSelection)
  306. const result = await this.$http.post('delModel', {
  307. delarr: that.delarry,
  308. })
  309. if (result.data.code == 0) {
  310. this.$message({
  311. type: 'success',
  312. message: '删除成功!'
  313. });
  314. this.delarry=[]
  315. that.getmodelList()
  316. } else {
  317. this.$message({
  318. type: 'error',
  319. message: '该模型已被绑定,不可删除!'
  320. });
  321. }
  322. this.$refs.multipleModelTable.clearSelection();
  323. },
  324. // 查询
  325. searchData(){
  326. this.queryInfo.pageNum=1
  327. this.getmodelList()
  328. },
  329. // 重置
  330. reset(){
  331. this.queryInfo.type_id=''
  332. this.getmodelList()
  333. },
  334. // 获取模型列表
  335. async getmodelList() {
  336. const {
  337. data: res
  338. } = await this.$http.post(
  339. "getModelList", this.queryInfo
  340. );
  341. console.log(res)
  342. for (let i = 0; i < res.data.rows.length; i++) {
  343. if (res.data.rows[i].type_id == '1') {
  344. res.data.rows[i].type = '种植业'
  345. } else if (res.data.rows[i].type_id == '2') {
  346. res.data.rows[i].type = '畜牧业'
  347. } else if (res.data.rows[i].type_id == '3') {
  348. res.data.rows[i].type = '渔业'
  349. }else{
  350. res.data.rows[i].type = '其他'
  351. }
  352. }
  353. this.tableData = res.data.rows
  354. this.total = res.data.total
  355. },
  356. // 查看列表详情
  357. async getmodelDetail(id) {
  358. console.log(id)
  359. const {
  360. data: res
  361. } = await this.$http.post(
  362. "getModeldetail", {id:id}
  363. );
  364. if(res.code==0){
  365. this.modelForm.id = res.data.name.id
  366. this.modelForm.name = res.data.name.name
  367. this.modelForm.type_id = res.data.name.type_id
  368. this.modelForm.product=res.data.product
  369. this.modelForm.pesticides=res.data.pesticides
  370. console.log(res.data.product.map(el=>el.product_name).join(','))
  371. this.productText = res.data.product.map(el=>el.product_name).join(',')
  372. this.pesticidesText = res.data.pesticides.map(el=>el.test_name).join(',')
  373. console.log(this.modelForm.pesticides)
  374. console.log(this.modelForm.product)
  375. }
  376. console.log(this.modelForm)
  377. this.readDialogVisible = true
  378. },
  379. /** 修复当用户在大于1的分页进行数据搜索没有返回值的问题 */
  380. setPageNum() {
  381. this.queryInfo1.pageNum = 1
  382. this.choseProbePackets()
  383. },
  384. /** 监听每页显示多少数据的改变 */
  385. handleSizeChange1(newSize) {
  386. this.queryInfo1.pageSize = newSize
  387. this.choseProbePackets()
  388. },
  389. /** 监听页码的改变 */
  390. handleCurrentChange1(newPage) {
  391. this.queryInfo1.pageNum = newPage
  392. this.choseProbePackets()
  393. },
  394. // 过滤树形结构关键字
  395. filterNode(value, data) {
  396. if (!value) return true;
  397. return data.name.indexOf(value) !== -1;
  398. },
  399. // 选择检测对象
  400. async choseMonitoringTarget() {
  401. const result = await this.$http.post('getProductList', {
  402. type_id: this.modelForm.type_id
  403. })
  404. console.log(this.modelForm.type_id)
  405. // 判断业务逻辑
  406. if (result.data.code == 0) {
  407. this.monitoringTargetList = result.data.data
  408. }
  409. },
  410. // 获取检测包
  411. async choseProbePackets() {
  412. const result = await this.$http.post('getPesticidesList', this.queryInfo1)
  413. // 判断业务逻辑
  414. if (result.data.code == 0) {
  415. this.pesticidesList = result.data.data.rows
  416. this.total1 = result.data.data.total
  417. }
  418. },
  419. // 搜索检测项
  420. async searchData1() {
  421. this.queryInfo1.pageNum = 1
  422. this.choseProbePackets()
  423. },
  424. // 选中检测对象
  425. choseMonitor() {
  426. var that = this
  427. console.log(this.$refs.tree.getCheckedNodes());
  428. let res = this.$refs.tree.getCheckedNodes()
  429. that.productText = res.map(el => el.name).join(', ')
  430. that.modelForm.product = this.$refs.tree.getCheckedNodes()
  431. that.choseMonitoringTargetShow=false
  432. },
  433. setSelectedRow() {
  434. // 设置当前页已选项
  435. this.hander = true
  436. this.pesticidesList.forEach(item => {
  437. if (this.list.includes(item[this.uniqueKey])) {
  438. this.$refs.multipleTable.toggleRowSelection(item, true)
  439. }
  440. })
  441. this.hander = false
  442. },
  443. // 提交选中检测包
  444. choseProbe() {
  445. let that = this
  446. // console.log(that.orgs)
  447. that.pesticidesText = that.multipleSelection.map(el => el.name).join(', ')
  448. console.log(that.pesticides_name)
  449. that.modelForm.pesticides=that.multipleSelection
  450. console.log(that.modelForm.pesticides)
  451. // that.form.pesticides = that.multipleSelection
  452. // for(let i=0;i<that.multipleSelection.length;i++){
  453. // that.form.main_unit.push(that.multipleSelection[i].name)
  454. // }
  455. that.choseProbePacketsShow = false
  456. },
  457. // 批量勾选
  458. handleSelectionChange(val) {
  459. this.multipleSelection = val
  460. console.log(this.multipleSelection)
  461. if (this.hander) return false
  462. // this.setSelectRows() // 处理选中的方法
  463. },
  464. // 提交模型表单
  465. async onSubmit(id) {
  466. console.log(this.modelForm)
  467. const result = await this.$http.post('DoEditModelInfo', this.modelForm)
  468. // 判断业务逻辑
  469. if (result.data.code == 0) {
  470. this.$message({
  471. type: 'success',
  472. message: '提交成功!'
  473. });
  474. this.readDialogVisible = false
  475. this.getmodelList()
  476. }
  477. },
  478. },
  479. }
  480. </script>
  481. <style lang="less" scoped>
  482. .el-table {
  483. align-items: center;
  484. margin-top: 25px;
  485. }
  486. /deep/ .el-col {
  487. padding-right: 0 !important;
  488. }
  489. /deep/ .el-radio-group label {
  490. width: 180px;
  491. margin-right: 10px;
  492. }
  493. .el-pagination {
  494. margin-top: 25px;
  495. }
  496. // .el-cascader {
  497. // width: 290px;
  498. // }
  499. .el-select {
  500. width: 210px;
  501. height: 100%;
  502. }
  503. .select {
  504. display: flex;
  505. flex-direction: row;
  506. margin-left: 10px;
  507. }
  508. .dialogItem /deep/ .el-dialog__body {
  509. padding: 15px 12px 0;
  510. color: #606266;
  511. font-size: 14px;
  512. word-break: break-all;
  513. }
  514. .labelItem /deep/ .el-form-item__label {
  515. // width: 80px;
  516. text-align: center;
  517. vertical-align: middle;
  518. float: left;
  519. font-size: 13px;
  520. color: #606266;
  521. // line-height: 40px;
  522. padding: 0 2px 0 0;
  523. -webkit-box-sizing: border-box;
  524. box-sizing: border-box;
  525. }
  526. .el-form-item {
  527. margin-bottom: 8px;
  528. padding-left: 18px;
  529. }
  530. .labelItem /deep/ .el-form-item__label {
  531. // width: 80px;
  532. text-align: center;
  533. vertical-align: middle;
  534. float: left;
  535. font-size: 13px;
  536. color: #606266;
  537. // line-height: 40px;
  538. padding: 0 2px 0 0;
  539. -webkit-box-sizing: border-box;
  540. box-sizing: border-box;
  541. }
  542. .footer {
  543. padding: 5px 0;
  544. border-top: 1px solid #e5e5e5;
  545. text-align: center;
  546. }
  547. // .el-form-item__content{
  548. // margin-left: 0;
  549. // }
  550. </style>