index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @defaultOrg="getDefaultOrg"
  10. @checkChange="checkChange"
  11. @click="clickTreeNode"
  12. ></org-tree>
  13. </el-col>
  14. <el-col :span="20" :xs="24">
  15. <div class="main-right-box">
  16. <div class="main-search-box">
  17. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
  18. <el-form-item label="设备名称" prop="deviceName">
  19. <el-input clearable v-model="queryParams.deviceName" placeholder="请输入关键字" maxlength="50"
  20. @keyup.enter.native="handleQuery"/>
  21. </el-form-item>
  22. <el-form-item label="资产分类" prop="assetType" label-width="80">
  23. <el-select style="width: 100%;" v-model="queryParams.assetType" placeholder="请选择资产分类"
  24. @change="queryAssetSelectChange" @clear="clearAsset" clearable>
  25. <el-option v-for="item in getAssetDict('AssetDeviceType',-1)" :key="item.id" :label="item.name"
  26. :value="item.id"></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="设备分类" prop="deviceType" label-width="80">
  30. <el-select style="width: 100%;" clearable v-model="queryParams.deviceType" placeholder="请选择设备分类">
  31. <el-option v-for="item in assetChildrenDictList" :key="item.id" :label="item.name"
  32. :value="item.id"></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10">
  37. <el-col :span="1.5">
  38. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  39. </el-col>
  40. <el-col :span="1.5">
  41. <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
  45. v-hasPermi="['system:device:add']">新增设备
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button type="primary" icon="el-icon-upload" size="mini" @click="handleImport"
  50. v-hasPermi="['system:device:importData']">导入设备
  51. </el-button>
  52. </el-col>
  53. <el-col :span="1.5">
  54. <el-button type="primary" icon="el-icon-download" size="mini" @click="handleOut"
  55. v-hasPermi="['system:device:export']">导出模版
  56. </el-button>
  57. </el-col>
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. </div>
  61. <el-table border height="646" size="small" v-loading="loading" :data="deviceList"
  62. @selection-change="handleSelectionChange">
  63. <el-table-column label="序号" align="center" min-width="50">
  64. <template v-slot:default="scope">
  65. <span v-text="getPageIndex(scope.$index)"> </span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="地区" align="left" prop="affiliatedArea"/>
  69. <el-table-column label="行社" align="left" prop="affiliatedBank"/>
  70. <el-table-column label="所属机构" align="left" prop="orgName"/>
  71. <el-table-column label="资产分类" align="center" key="assetType" prop="assetType"/>
  72. <el-table-column label="设备分类" align="center" key="deviceType" prop="deviceType"/>
  73. <el-table-column label="设备名称" align="center" prop="deviceName"/>
  74. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  75. <template slot-scope="scope">
  76. <el-button size="mini" type="text" icon="el-icon-edit-outline" @click="handleUpdate(scope.row)"
  77. v-hasPermi="['system:device:edit']">编辑
  78. </el-button>
  79. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  80. v-hasPermi="['system:device:remove']">删除
  81. </el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  86. @pagination="getList"/>
  87. </div>
  88. </el-col>
  89. </el-row>
  90. <!-- 添加或修改【请填写功能名称】对话框 -->
  91. <DialogCom
  92. :title="title"
  93. :visible.sync="open"
  94. width="850px"
  95. @close="closeHandler"
  96. append-to-body
  97. >
  98. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  99. <el-row>
  100. <el-col :span="24">
  101. <el-form-item label="所属机构" prop="orgId">
  102. <tree-select
  103. v-model="form.orgId"
  104. :options="deptOptions"
  105. :show-count="true"
  106. :normalizer="tenantIdnormalizer"
  107. :props="{ checkStrictly: true, label: 'name' }"
  108. placeholder="请选择所属机构"
  109. @select="changeSelect"
  110. clearValueText="清除"
  111. :noChildrenText="''"
  112. noOptionsText="没有数据"
  113. noResultsText="没有搜索结果"
  114. />
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. <el-row>
  119. <el-col :span="12">
  120. <el-form-item label="资产编号" prop="assetNo">
  121. <el-input
  122. v-model="form.assetNo"
  123. placeholder="请输入资产编号"
  124. maxlength="50"
  125. />
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="12">
  129. <el-form-item label="设备名称" prop="deviceName">
  130. <el-input
  131. v-model="form.deviceName"
  132. placeholder="请输入设备名称"
  133. maxlength="50"
  134. />
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. <el-row>
  139. <el-col :span="12">
  140. <el-form-item label="资产分类" prop="assetType">
  141. <el-select style="width: 100%" v-model="form.assetType" :popper-append-to-body="false"
  142. placeholder="请选择资产分类" @change="assetSelectChange">
  143. <el-option v-for="item in getAssetDict('AssetDeviceType',-1)" :key="item.id" :label="item.name"
  144. :value="item.id"></el-option>
  145. </el-select>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="12">
  149. <el-form-item label="设备分类" prop="deviceType">
  150. <el-select style="width: 100%" :popper-append-to-body="false" clearable v-model="form.deviceType"
  151. placeholder="请选择设备分类">
  152. <el-option v-for="item in assetChildrenDictList" :key="item.id" :label="item.name"
  153. :value="item.id"></el-option>
  154. </el-select>
  155. </el-form-item>
  156. </el-col>
  157. </el-row>
  158. <el-row>
  159. <el-col :span="12">
  160. <el-form-item label="设备品牌" prop="deviceBrand">
  161. <el-select style="width: 100%" v-model="form.deviceBrand" placeholder="请选择设备品牌"
  162. @change="brandSelectChange">
  163. <el-option v-for="item in getAssetDict('BrandModelType',-1)" :key="item.id" :label="item.name"
  164. :value="item.id"></el-option>
  165. </el-select>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="12">
  169. <el-form-item label="设备型号" prop="deviceModel">
  170. <el-select @change="brandSelectChange1" style="width: 100%" v-model="form.deviceModel" placeholder="请选择设备型号">
  171. <el-option v-for="item in brandChildrenDictList" :key="item.id" :label="item.name"
  172. :value="item.id"></el-option>
  173. </el-select>
  174. </el-form-item>
  175. </el-col>
  176. </el-row>
  177. <el-row>
  178. <el-col :span="12">
  179. <el-form-item label="采购日期" prop="purchasingTime">
  180. <el-date-picker style="width: 100%" clearable v-model="form.purchasingTime" type="date"
  181. value-format="yyyy-MM-dd" placeholder="请选择采购日期">
  182. </el-date-picker>
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="12">
  186. <el-form-item label="安装位置" prop="address">
  187. <el-input v-model="form.address" placeholder="请输入安装位置" maxlength="50"/>
  188. </el-form-item>
  189. </el-col>
  190. </el-row>
  191. <el-row>
  192. <el-col :span="12">
  193. <el-form-item label="消防类有效期" prop="checkTime">
  194. <el-date-picker style="width: 100%" clearable v-model="form.checkTime" type="date"
  195. value-format="yyyy-MM-dd" placeholder="请选择消防类有效期">
  196. </el-date-picker>
  197. </el-form-item>
  198. </el-col>
  199. <el-col :span="12">
  200. <el-form-item label="保修期限" prop="maintenanceTerm">
  201. <el-date-picker style="width: 100%" clearable v-model="form.maintenanceTerm" type="date"
  202. value-format="yyyy-MM-dd" placeholder="请选择保修期限">
  203. </el-date-picker>
  204. </el-form-item>
  205. </el-col>
  206. </el-row>
  207. <el-row>
  208. <el-col :span="12">
  209. <el-form-item label="投产时间" prop="useTime">
  210. <el-date-picker style="width: 100%" clearable v-model="form.useTime" type="date"
  211. value-format="yyyy-MM-dd" placeholder="请选择投产时间">
  212. </el-date-picker>
  213. </el-form-item>
  214. </el-col>
  215. <el-col :span="12">
  216. <el-form-item label="资产状态" prop="deviceStatus">
  217. <el-select
  218. v-model="form.deviceStatus"
  219. clearable
  220. placeholder="请选择资产状态"
  221. style="width: 100%;">
  222. <el-option
  223. v-for="dict in dict.type.asset_status"
  224. :key="dict.value"
  225. :label="dict.label"
  226. :value="`${dict.value}`"
  227. ></el-option>
  228. </el-select>
  229. </el-form-item>
  230. </el-col>
  231. </el-row>
  232. </el-form>
  233. <div slot="footer" class="dialog-footer">
  234. <el-button type="primary" @click="submitForm">确 定</el-button>
  235. <el-button @click="cancel">取 消</el-button>
  236. </div>
  237. </DialogCom>
  238. <!-- 设备导入对话框 -->
  239. <DialogCom
  240. :title="upload.title"
  241. :visible.sync="upload.open"
  242. width="400px"
  243. append-to-body
  244. >
  245. <el-upload
  246. ref="upload"
  247. :limit="1"
  248. accept=".xlsx, .xls"
  249. :headers="upload.headers"
  250. :action="upload.url"
  251. :disabled="upload.isUploading"
  252. :on-progress="handleFileUploadProgress"
  253. :on-success="handleFileSuccess"
  254. :auto-upload="false"
  255. :before-upload="beforeUpload"
  256. drag
  257. >
  258. <i class="el-icon-upload"></i>
  259. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  260. </el-upload>
  261. <div slot="footer" class="dialog-footer">
  262. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  263. <el-button @click="upload.open = false">取 消</el-button>
  264. </div>
  265. </DialogCom>
  266. </div>
  267. </template>
  268. <script>
  269. import {getToken} from "@/utils/auth";
  270. import orgDropDown from "../../../components/orgTree/orgDropDown.vue";
  271. import OrgTree from "@/components/orgTree";
  272. import tableList from "@/mixins/tableList";
  273. import {deptTreeSelect} from "@/api/system/public";
  274. import {getDeviceType} from "@/api/system/dict/data";
  275. import {
  276. addDevice,
  277. delDevice,
  278. getDevice, getDictList,
  279. getDictTree, getDictTreeByParentId,
  280. getHostByOrgId,
  281. listDevice,
  282. updateDevice,
  283. } from "@/api/system/device";
  284. import request from "@/utils/request";
  285. export default {
  286. /** 引入基础minxins*/
  287. mixins: [tableList],
  288. dicts: ["sys_asset_type", "sys_device_type",'asset_status'],
  289. name: "Device",
  290. components: {OrgTree, orgDropDown},
  291. data() {
  292. return {
  293. checkList: [],
  294. roleOptions: [],
  295. defaultKeys: [],
  296. //是否关联下级
  297. checked: false,
  298. defaultProps: {
  299. children: "children",
  300. label: "name",
  301. },
  302. rules: {
  303. assetNo: [{required: true, message: "请输入资产编号", trigger: "change"}],
  304. deviceName: [{required: true, message: "请输入设备名称", trigger: "change"}],
  305. orgId: [{required: true, message: "请选择所属机构", trigger: "blur"}],
  306. assetType: [{required: true, message: '请选择资产分类', trigger: 'change'}],
  307. /* hostId: [{required: true, message: '请选择主机', trigger: 'change'}],
  308. channel: [{required: true, message: '请输入通道号', trigger: 'change'}],*/
  309. deviceType: [{required: true, message: "请选择设备分类", trigger: "change"}],
  310. deviceStatus: [{required: true, message: "请选择资产状态", trigger: "blur"}],
  311. },
  312. // 遮罩层
  313. loading: true,
  314. // 选中数组
  315. ids: [],
  316. // 非单个停用
  317. single: true,
  318. //搜索tree
  319. deptName: null,
  320. // 显示搜索条件
  321. showSearch: true,
  322. // 总条数
  323. total: 0,
  324. inparm: 0,
  325. // 【请填写功能名称】表格数据
  326. deviceList: [],
  327. devices: null,
  328. searchDevices: null,
  329. //主机集合
  330. hostList: [],
  331. dictionaryTreeList: [],
  332. dictionaryList: [],
  333. assetChildrenDictList: [],
  334. brandChildrenDictList: [],
  335. deviceType: 0,
  336. // 弹出层标题
  337. title: "",
  338. // 是否显示弹出层
  339. open: false,
  340. // 查询参数
  341. dept: {
  342. id: null,
  343. },
  344. queryParams: {
  345. pageNum: 1,
  346. pageSize: 10,
  347. orgId: null,
  348. orgName: null,
  349. deviceName: null,
  350. assetType: null,
  351. deviceType: null,
  352. deviceBrand: null,
  353. checkTime: null,
  354. maintenanceTerm: null,
  355. hostId: null,
  356. channel: null,
  357. checkSub: true,
  358. },
  359. // 设备导入参数
  360. upload: {
  361. // 是否显示弹出层(用户导入)
  362. open: false,
  363. // 弹出层标题(用户导入)
  364. title: "",
  365. // 是否停用上传
  366. isUploading: false,
  367. // 设置上传的请求头部
  368. headers: {Authorization: "Bearer " + getToken()},
  369. // 上传的地址
  370. url:
  371. process.env.NODE_ENV === "development"
  372. ? process.env.VUE_APP_BASE_API + "/system/device/importData"
  373. : window.origin + "/system/device/importData",
  374. },
  375. // 表单参数
  376. form: {
  377. orgId: null,
  378. deviceName: null,
  379. assetType: null,
  380. deviceType: null,
  381. deviceBrand: null,
  382. deviceModel: null,
  383. checkTime: null,
  384. maintenanceTerm: null,
  385. hostId: null,
  386. channel: null,
  387. address: null,
  388. definition: null,
  389. inBook: 0,
  390. purchasingTime: null,
  391. assetNo: null,
  392. deviceStatus: null,
  393. },
  394. // 表单校验
  395. //修改新增中的机构树
  396. deptOptions: [],
  397. selectOrgId: null,
  398. };
  399. },
  400. created() {
  401. this.getDeptTree();
  402. //this.getList();
  403. },
  404. mounted() {
  405. this.initDictionaryTreeList();
  406. this.initDictionaryList();
  407. },
  408. watch: {
  409. // 根据名称筛选部门树
  410. deptName(val) {
  411. this.$refs.tree.filter(val);
  412. },
  413. },
  414. methods: {
  415. onOrgSelect(node) {
  416. this.form.orgPath = node.path;
  417. this.form.orgName = node.name;
  418. },
  419. // 文件上传中处理
  420. handleFileUploadProgress(event, file, fileList) {
  421. this.upload.isUploading = true;
  422. },
  423. handleImport() {
  424. this.upload.title = "设备导入";
  425. this.upload.open = true;
  426. },
  427. // 文件上传成功处理
  428. handleFileSuccess(response, file, fileList) {
  429. this.upload.open = false;
  430. this.upload.isUploading = false;
  431. this.$refs.upload.clearFiles();
  432. this.$alert(
  433. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  434. response.msg +
  435. "</div>",
  436. "导入结果",
  437. {dangerouslyUseHTMLString: true}
  438. );
  439. this.getList();
  440. },
  441. beforeUpload(file) {
  442. // 返回 false 可以阻止文件上传
  443. // 创建 FormData 对象
  444. let config = {
  445. headers: {
  446. 'Content-Type': 'multipart/form-data'
  447. },
  448. responseType: 'blob'
  449. }
  450. const formData = new FormData();
  451. // 添加文件到 FormData
  452. formData.append("file", file);
  453. request.post(this.upload.url, formData, config)
  454. .then((response) => {
  455. // 在接收到后端响应时执行的逻辑
  456. // console.log(response,"response");
  457. this.upload.open = false;
  458. this.upload.isUploading = false;
  459. this.$refs.upload.clearFiles();
  460. if (response&&response.size >0) {
  461. this.$alert(
  462. "导入失败,请根据返回的Excel检查文件内容"
  463. );
  464. const blob = new Blob([response],
  465. {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}) //你需要的类型 转化为blob对象
  466. const url = window.URL.createObjectURL(blob) //将对象转化为链接
  467. let a = document.createElement('a')
  468. // 下载链接
  469. a.href = url
  470. a.download = '设备导入结果.xlsx'
  471. document.body.appendChild(a)
  472. // 点击a标签,进行下载
  473. a.click()
  474. // 移除元素
  475. document.body.removeChild(a)
  476. } else {
  477. this.$alert(
  478. "导入成功!"
  479. );
  480. }
  481. this.getList();
  482. })
  483. .catch((error) => {
  484. // 在请求失败时执行的逻辑
  485. // console.log(error,"error");
  486. });
  487. return false;
  488. },
  489. getDefaultOrg(org) {
  490. this.orgName = org.name;
  491. },
  492. getDefaultKey(key) {
  493. this.queryParams.orgId = key;
  494. this.getList();
  495. },
  496. //单选框状态改变
  497. checkChange(state) {
  498. this.queryParams.checkSub = state;
  499. this.handleQuery();
  500. },
  501. getPageIndex($index) {
  502. //表格序号
  503. return (
  504. (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
  505. );
  506. },
  507. /** 下穿状态改变*/
  508. changeCheckBox() {
  509. this.getList();
  510. },
  511. // 筛选节点
  512. filterNode(value, data) {
  513. if (!value) return true;
  514. return data.name.indexOf(value) !== -1;
  515. },
  516. /** 查询机构树数据 */
  517. // 节点单击事件
  518. handleNodeClick(data) {
  519. this.queryParams.orgId = data.id;
  520. this.selectOrgId = data.id;
  521. this.changeSelect(data);
  522. this.handleQuery();
  523. },
  524. changeSelect(val) {
  525. if (!val || !val.id) return;
  526. getHostByOrgId(val).then((response) => {
  527. this.form.hostId = null;
  528. this.hostList = response.data;
  529. });
  530. },
  531. handleOut() {
  532. this.download(
  533. "system/device/downInChargeOfTemplate",
  534. {
  535. ...this.queryParams,
  536. },
  537. `${
  538. this.orgName + "-设备导入模版-" + this.formatTime(new Date(), "YYYYMMhh")
  539. }.xlsx`
  540. );
  541. },
  542. /** 查询【请填写功能名称】列表 */
  543. getList() {
  544. this.loading = true;
  545. listDevice(this.queryParams).then((response) => {
  546. this.deviceList = response.rows;
  547. this.total = response.total;
  548. this.loading = false;
  549. });
  550. },
  551. /** 查询部门下拉树结构 */
  552. getDeptTree() {
  553. deptTreeSelect().then((response) => {
  554. this.deptOptions = response.data;
  555. this.defaultKeys.push(response.data[0].id);
  556. this.queryParams.orgId = response.data[0].id;
  557. this.selectOrgId = response.data[0].id;
  558. this.handleQuery();
  559. });
  560. },
  561. // 节点单击事件
  562. clickTreeNode(data) {
  563. this.queryParams.orgId = data.id;
  564. this.handleQuery();
  565. },
  566. /** treeSelect组件自定义数据*/
  567. tenantIdnormalizer(node, instanceId) {
  568. if (node.children && !node.children.length) {
  569. delete node.children;
  570. }
  571. return {
  572. id: node.id,
  573. label: node.shortName,
  574. children: node.children,
  575. };
  576. },
  577. // 取消按钮
  578. cancel() {
  579. this.open = false;
  580. this.reset();
  581. },
  582. closeHandler() {
  583. this.reset();
  584. },
  585. // 表单重置
  586. reset() {
  587. this.form = {
  588. id: null,
  589. orgId: null,
  590. orgName: null,
  591. assetNo: null,
  592. deviceName: null,
  593. assetType: null,
  594. deviceType: null,
  595. deviceBrand: null,
  596. deviceModel: null,
  597. purchasingTime: null,
  598. address: null,
  599. checkTime: null,
  600. maintenanceTerm: null,
  601. useTime: null,
  602. deviceStatus: null,
  603. hostId: null,
  604. channel: null,
  605. definition: "1",
  606. };
  607. this.resetForm("form");
  608. },
  609. /** 搜索按钮操作 */
  610. handleQuery() {
  611. this.queryParams.pageNum = 1;
  612. this.getList();
  613. },
  614. /** 重置按钮操作 */
  615. resetQuery() {
  616. this.devices = null;
  617. this.searchDevices = null;
  618. this.resetForm("queryForm");
  619. this.handleQuery();
  620. },
  621. // 多选框选中数据
  622. handleSelectionChange(selection) {
  623. this.ids = selection.map((item) => item.id);
  624. this.names = selection.map((item) => item.deviceName);
  625. this.single = selection.length !== 1;
  626. },
  627. /** 新增按钮操作 */
  628. handleAdd(val) {
  629. this.open = true;
  630. this.title = "新增设备信息";
  631. this.form.orgId = this.selectOrgId;
  632. this.dept.id = this.selectOrgId;
  633. this.changeSelect(this.dept);
  634. this.devices = null;
  635. },
  636. //获取字典数据
  637. initDictionaryTreeList() {
  638. getDictTree().then((response) => {
  639. this.dictionaryTreeList = response.data;
  640. });
  641. },
  642. initDictionaryList() {
  643. getDictList().then((response) => {
  644. this.dictionaryList = response.data;
  645. });
  646. },
  647. //从基础数据中获取资产分类
  648. getAssetDict(type, parentId) {
  649. let arr = []
  650. this.dictionaryTreeList.filter(item => item.type === type && item.parentId == parentId).map(item => {
  651. arr.push(item);
  652. });
  653. return arr;
  654. },
  655. //从基础数据中获取资产分类
  656. getAssetDictDetailInfo(id) {
  657. let arr = []
  658. this.dictionaryList.filter(item => item.id == id).map(item => {
  659. arr.push(item);
  660. });
  661. return arr;
  662. },
  663. //新增设备时
  664. assetSelectChange(val) {
  665. if (!val) return;
  666. this.form.deviceType = null;
  667. getDictTreeByParentId(val).then((response) => {
  668. this.assetChildrenDictList = response.data;
  669. console.log('获取设备分类数据', this.assetChildrenDictList);
  670. });
  671. },
  672. //查询时
  673. queryAssetSelectChange(val) {
  674. if (!val) return;
  675. this.queryParams.deviceType = null;
  676. getDictTreeByParentId(val).then((response) => {
  677. this.assetChildrenDictList = response.data;
  678. console.log('获取设备分类数据', this.assetChildrenDictList);
  679. });
  680. },
  681. brandSelectChange(val) {
  682. if (!val) return;
  683. this.form.deviceModel = null;
  684. getDictTreeByParentId(val).then((response) => {
  685. this.brandChildrenDictList = response.data;
  686. console.log('获取设备型号数据', this.brandChildrenDictList);
  687. });
  688. },
  689. brandSelectChange1(val) {
  690. console.log(this.form.deviceModel,val)
  691. },
  692. clearAsset() {
  693. this.queryParams.deviceType = null;
  694. },
  695. /** 修改按钮操作 */
  696. handleUpdate(row) {
  697. this.reset();
  698. const id = row.id || this.ids;
  699. getDevice(id).then((response) => {
  700. this.form = response.data;
  701. this.open = true;
  702. this.title = "编辑设备信息";
  703. console.log(this.form.assetType,this.form.deviceBrand)
  704. getDictTreeByParentId(this.form.assetType).then((response) => {
  705. this.assetChildrenDictList = response.data;
  706. });
  707. getDictTreeByParentId(this.form.deviceBrand).then((response) => {
  708. this.brandChildrenDictList = response.data;
  709. });
  710. });
  711. },
  712. /** 提交按钮 */
  713. submitForm() {
  714. this.$refs["form"].validate((valid) => {
  715. if (valid) {
  716. if (this.form.id != null) {
  717. updateDevice(this.form).then((response) => {
  718. this.$modal.msgSuccess("处理成功");
  719. this.open = false;
  720. this.getList();
  721. });
  722. } else {
  723. addDevice(this.form).then((response) => {
  724. this.$modal.msgSuccess("处理成功");
  725. this.open = false;
  726. this.getList();
  727. });
  728. }
  729. }
  730. });
  731. },
  732. /** 删除按钮操作 */
  733. handleDelete(row) {
  734. const ids = row.id || this.ids;
  735. const names = row.deviceName || this.names;
  736. this.$modal
  737. .confirm('是否确认删除名称为"' + names + '"的数据项?')
  738. .then(function () {
  739. return delDevice(ids);
  740. })
  741. .then(() => {
  742. this.getList();
  743. this.$modal.msgSuccess("删除成功");
  744. })
  745. .catch(() => {
  746. });
  747. },
  748. // 提交上传文件
  749. submitFileForm() {
  750. this.$refs.upload.submit();
  751. },
  752. /** 导出按钮操作 */
  753. handleExport() {
  754. this.download(
  755. "system/device/export",
  756. {
  757. ...this.queryParams,
  758. },
  759. `device_${new Date().getTime()}.xlsx`
  760. );
  761. },
  762. },
  763. };
  764. </script>
  765. <style lang="scss">
  766. //.vue-treeselect--has-value .vue-treeselect__input {
  767. // line-height: 100%;
  768. // vertical-align: middle;
  769. //}
  770. </style>