equipment.vue 10 KB

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