index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. label-width="88px"
  8. >
  9. <el-form-item label="设备类型" prop="deviceType">
  10. <el-select
  11. v-model="queryParams.deviceType"
  12. clearable
  13. placeholder="请选择"
  14. >
  15. <el-option
  16. v-for="dict in deviceTypeOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. ></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="设备序列号" prop="deviceSerialNum">
  24. <el-input
  25. v-model="queryParams.deviceSerialNum"
  26. placeholder="请输入设备序列号"
  27. clearable
  28. size="small"
  29. @keyup.enter.native="handleQuery"
  30. />
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button
  34. type="cyan"
  35. icon="el-icon-search"
  36. size="mini"
  37. @click="handleQuery"
  38. >搜索</el-button
  39. >
  40. <el-button
  41. type="info"
  42. icon="el-icon-refresh"
  43. size="mini"
  44. @click="resetQuery"
  45. >重置</el-button
  46. >
  47. <el-button
  48. type="primary"
  49. icon="el-icon-plus"
  50. size="mini"
  51. @click="handleAdd"
  52. >新增</el-button
  53. >
  54. </el-form-item>
  55. </el-form>
  56. <el-table :data="manageList">
  57. <el-table-column
  58. label="主键自增id"
  59. v-if="false"
  60. align="center"
  61. prop="deviceId"
  62. />
  63. <el-table-column label="油站名称" align="center" prop="stationName" />
  64. <el-table-column
  65. label="设备序列号"
  66. align="center"
  67. prop="deviceSerialNum"
  68. />
  69. <el-table-column label="设备厂家" align="center" prop="deviceFactory" />
  70. <el-table-column
  71. label="油站名称id"
  72. v-if="false"
  73. align="center"
  74. prop="stationId"
  75. />
  76. <el-table-column label="绑定油枪号" align="center" prop="gunNo" />
  77. <el-table-column
  78. label="操作"
  79. align="center"
  80. class-name="small-padding fixed-width"
  81. >
  82. <template slot-scope="scope">
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-edit"
  87. @click="handleUpdate(scope.row)"
  88. >修改</el-button
  89. >
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-delete"
  94. @click="handleDelete(scope.row)"
  95. >删除</el-button
  96. >
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination
  101. :total="100"
  102. :page.sync="queryParams.pageNum"
  103. :limit.sync="queryParams.pageSize"
  104. @pagination="getList"
  105. />
  106. <!-- 添加或修改油站设备管理对话框 -->
  107. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  108. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  109. <el-form-item label="设备编号" prop="deviceNo">
  110. <el-input v-model="form.deviceNo" placeholder="请输入设备编号" />
  111. </el-form-item>
  112. <el-form-item label="设备名称" prop="deviceName">
  113. <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
  114. </el-form-item>
  115. <el-form-item label="设备序列号" prop="deviceSerialNum">
  116. <el-input
  117. v-model="form.deviceSerialNum"
  118. placeholder="请输入设备序列号"
  119. />
  120. </el-form-item>
  121. <el-form-item label="设备类型">
  122. <el-select
  123. v-model="form.deviceType"
  124. placeholder="请选择"
  125. clearable
  126. size="small"
  127. >
  128. <el-option
  129. v-for="dict in deviceTypeOptions"
  130. :key="dict.dictValue"
  131. :label="dict.dictLabel"
  132. :value="dict.dictValue"
  133. ></el-option>
  134. </el-select>
  135. </el-form-item>
  136. <el-form-item label="绑定油枪号" prop="gunNo">
  137. <el-checkbox-group v-model="gunNoList">
  138. <el-checkbox
  139. v-for="item in checkList"
  140. :key="item.oilGunId"
  141. :label="item.oilGunNo"
  142. :value="item.oilGunNo"
  143. >
  144. {{ item.oilGunNo + "号枪/" + item.oilName }}
  145. </el-checkbox>
  146. </el-checkbox-group>
  147. </el-form-item>
  148. <el-form-item label="设备状态">
  149. <el-select
  150. v-model="form.deviceStatus"
  151. clearable
  152. size="small"
  153. placeholder="请选择"
  154. >
  155. <el-option
  156. v-for="dict in deviceStatusOptions"
  157. :key="dict.dictValue"
  158. :label="dict.dictLabel"
  159. :value="dict.dictValue"
  160. ></el-option>
  161. </el-select>
  162. </el-form-item>
  163. <el-form-item label="设备厂家" prop="deviceFactory">
  164. <el-input v-model="form.deviceFactory" placeholder="请输入设备厂家" />
  165. </el-form-item>
  166. </el-form>
  167. <div slot="footer" class="dialog-footer">
  168. <el-button type="primary" @click="submitForm">确 定</el-button>
  169. <el-button @click="cancel">取 消</el-button>
  170. </div>
  171. </el-dialog>
  172. </div>
  173. </template>
  174. <script>
  175. import {
  176. listManage,
  177. getManage,
  178. delManage,
  179. addManage,
  180. updateManage,
  181. exportManage,
  182. changeManageStatus,
  183. } from "@/api/station/manage";
  184. import { listGun } from "@/api/station/gun";
  185. import { getDept } from "@/api/system/dept";
  186. export default {
  187. name: "Manage",
  188. data() {
  189. return {
  190. // 非单个禁用
  191. single: true,
  192. // 非多个禁用
  193. multiple: true,
  194. // 总条数
  195. total: 0,
  196. // 油站设备管理表格数据
  197. manageList: [],
  198. //油枪复选
  199. checkList: [],
  200. gunNoList: [],
  201. //设备状态
  202. deviceStatusOptions: [],
  203. //设备类型
  204. deviceTypeOptions: [],
  205. stationOptions: [],
  206. // 弹出层标题
  207. title: "",
  208. // 是否显示弹出层
  209. open: false,
  210. // 查询参数
  211. queryParams: {
  212. pageNum: 1,
  213. pageSize: 10,
  214. deviceNo: null,
  215. stationId: this.deptId,
  216. deviceType: null,
  217. deviceSerialNum: null,
  218. },
  219. deptId: null,
  220. queryInfo: {
  221. stationId: null,
  222. },
  223. // 查询参数
  224. deptInfo: {},
  225. query: {
  226. deptId: null,
  227. },
  228. // 表单参数
  229. form: {},
  230. // 表单校验
  231. rules: {},
  232. };
  233. },
  234. created() {
  235. this.getList();
  236. //字典设备状态
  237. this.getDicts("device_status").then((response) => {
  238. this.deviceStatusOptions = response.data;
  239. });
  240. //字典设备类型
  241. this.getDicts("device_type").then((response) => {
  242. this.deviceTypeOptions = response.data;
  243. });
  244. },
  245. methods: {
  246. /** 查询油站设备管理列表 */
  247. getList() {
  248. listManage(this.queryParams).then((response) => {
  249. this.manageList = response.rows;
  250. this.total = response.total;
  251. });
  252. },
  253. // 取消按钮
  254. cancel() {
  255. this.open = false;
  256. this.reset();
  257. },
  258. // 表单重置
  259. reset() {
  260. this.form = {
  261. deviceId: null,
  262. deviceNo: null,
  263. deviceName: null,
  264. stationId: null,
  265. stationName: null,
  266. deviceType: null,
  267. deviceSerialNum: null,
  268. gunNo: null,
  269. deviceStatus: null,
  270. deviceFactory: null,
  271. };
  272. this.resetForm("form");
  273. this.gunNoList.length = 0;
  274. },
  275. deviceStatusFotmat(row, column) {
  276. if (row.deviceStatus === "1") {
  277. return "在用";
  278. } else if (row.deviceStatus === "2") {
  279. return "停用";
  280. }
  281. },
  282. /** 搜索按钮操作 */
  283. handleQuery() {
  284. this.queryParams.pageNum = 1;
  285. this.getList();
  286. },
  287. /** 重置按钮操作 */
  288. resetQuery() {
  289. this.resetForm("queryForm");
  290. this.handleQuery();
  291. },
  292. /** 新增按钮操作 */
  293. handleAdd() {
  294. if (this.jiBie === 2) {
  295. this.open = true;
  296. this.title = "添加油站设备管理";
  297. this.form.stationId = this.deptInfo.deptId;
  298. this.form.stationName = this.deptInfo.deptName;
  299. this.queryInfo.stationId = this.deptInfo.deptId;
  300. listGun(this.queryInfo).then((response) => {
  301. console.log(response);
  302. this.checkList = response.rows;
  303. });
  304. } else {
  305. this.msgSuccess("请登录对应的账号");
  306. }
  307. },
  308. /** 修改按钮操作 */
  309. handleUpdate(row) {
  310. this.reset();
  311. const deviceId = row.deviceId;
  312. getManage(deviceId).then((response) => {
  313. this.form = response.data;
  314. if (this.form.gunNo != null && this.form.gunNo != "") {
  315. this.gunNoList = this.form.gunNo.split(",");
  316. }
  317. this.queryInfo.stationId = this.form.stationId;
  318. listGun(this.queryInfo).then((response) => {
  319. this.checkList = response.rows;
  320. });
  321. this.open = true;
  322. this.title = "修改油站设备管理";
  323. });
  324. },
  325. /** 提交按钮 */
  326. submitForm() {
  327. this.$refs["form"].validate((valid) => {
  328. if (valid) {
  329. if (this.gunNoList != null && this.gunNoList.length > 0) {
  330. this.form.gunNo = this.gunNoList.toString();
  331. }
  332. if (this.form.deviceId != null) {
  333. updateManage(this.form).then((response) => {
  334. this.msgSuccess("修改成功");
  335. this.open = false;
  336. this.getList();
  337. });
  338. } else {
  339. addManage(this.form).then((response) => {
  340. this.msgSuccess("新增成功");
  341. this.open = false;
  342. this.getList();
  343. });
  344. }
  345. }
  346. });
  347. },
  348. /** 删除按钮操作 */
  349. handleDelete(row) {
  350. const deviceIds = row.deviceId;
  351. this.$confirm("是否确认删除油站设备管理", "警告", {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. type: "warning",
  355. })
  356. .then(function () {
  357. return delManage(deviceIds);
  358. })
  359. .then(() => {
  360. this.getList();
  361. this.msgSuccess("删除成功");
  362. });
  363. },
  364. onInstitutionChang(e) {
  365. let obj = {};
  366. obj = this.stationOptions.find((item) => {
  367. //这里的userList就是上面遍历的数据源
  368. return item.deptId === e; //筛选出匹配数据
  369. });
  370. this.form.stationName = obj.deptName;
  371. this.queryInfo.stationId = obj.deptId;
  372. listGun(this.queryInfo).then((response) => {
  373. this.checkList = response.rows;
  374. });
  375. },
  376. /** 导出按钮操作 */
  377. handleExport() {
  378. const queryParams = this.queryParams;
  379. this.$confirm("是否确认导出所有油站设备管理数据项?", "警告", {
  380. confirmButtonText: "确定",
  381. cancelButtonText: "取消",
  382. type: "warning",
  383. })
  384. .then(function () {
  385. return exportManage(queryParams);
  386. })
  387. .then((response) => {
  388. this.download(response.msg);
  389. });
  390. },
  391. },
  392. };
  393. </script>