index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="设备条形码" prop="assetBarCode">
  5. <el-input
  6. v-model="queryParams.assetBarCode"
  7. placeholder="请输入设备条形码"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="报备人" prop="userId">
  13. <el-input
  14. v-model="queryParams.userId"
  15. placeholder="请输入报备人"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="报备时间" prop="reportDate">
  21. <el-date-picker clearable
  22. v-model="queryParams.reportDate"
  23. type="date"
  24. value-format="yyyy-MM-dd"
  25. placeholder="请选择报备时间">
  26. </el-date-picker>
  27. </el-form-item>
  28. <el-form-item label="处理状态" prop="processState">
  29. <el-select v-model="queryParams.processState" placeholder="请选择处理状态" clearable>
  30. <el-option
  31. v-for="dict in dict.type.asset_fault_process_state"
  32. :key="dict.value"
  33. :label="dict.label"
  34. :value="dict.value"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  40. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  41. </el-form-item>
  42. </el-form>
  43. <el-row :gutter="10" class="mb8">
  44. <el-col :span="1.5">
  45. <el-button
  46. type="primary"
  47. plain
  48. icon="el-icon-plus"
  49. size="mini"
  50. @click="handleAdd"
  51. v-hasPermi="['asset:fault:add']"
  52. >新增</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="success"
  57. plain
  58. icon="el-icon-edit"
  59. size="mini"
  60. :disabled="single"
  61. @click="handleUpdate"
  62. v-hasPermi="['asset:fault:edit']"
  63. >修改</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="danger"
  68. plain
  69. icon="el-icon-delete"
  70. size="mini"
  71. :disabled="multiple"
  72. @click="handleDelete"
  73. v-hasPermi="['asset:fault:remove']"
  74. >删除</el-button>
  75. </el-col>
  76. <el-col :span="1.5">
  77. <el-button
  78. type="warning"
  79. plain
  80. icon="el-icon-download"
  81. size="mini"
  82. @click="handleExport"
  83. v-hasPermi="['asset:fault:export']"
  84. >导出</el-button>
  85. </el-col>
  86. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  87. </el-row>
  88. <el-table v-loading="loading" :data="faultList" @selection-change="handleSelectionChange">
  89. <el-table-column type="selection" width="55" align="center" />
  90. <el-table-column label="报备编号" align="center" prop="id" />
  91. <el-table-column label="设备条形码" align="center" prop="assetBarCode" />
  92. <el-table-column label="报备人" align="center" prop="userId" />
  93. <el-table-column label="报备时间" align="center" prop="reportDate" width="180">
  94. <template slot-scope="scope">
  95. <span>{{ parseTime(scope.row.reportDate, '{y}-{m}-{d}') }}</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="故障现象" align="center" prop="faultPhenomenon" />
  99. <el-table-column label="报备人电话" align="center" prop="tel" />
  100. <el-table-column label="处理状态" align="center" prop="processState">
  101. <template slot-scope="scope">
  102. <dict-tag :options="dict.type.asset_fault_process_state" :value="scope.row.processState"/>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="处理结果" align="center" prop="processResult" />
  106. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  107. <template slot-scope="scope">
  108. <el-button
  109. size="mini"
  110. type="text"
  111. icon="el-icon-edit"
  112. @click="handleUpdate(scope.row)"
  113. v-hasPermi="['asset:fault:edit']"
  114. >修改</el-button>
  115. <el-button
  116. size="mini"
  117. type="text"
  118. icon="el-icon-delete"
  119. @click="handleDelete(scope.row)"
  120. v-hasPermi="['asset:fault:remove']"
  121. >删除</el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination
  126. v-show="total>0"
  127. :total="total"
  128. :page.sync="queryParams.pageNum"
  129. :limit.sync="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. <!-- 添加或修改故障报备对话框 -->
  133. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  134. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  135. <el-form-item label="设备条形码" prop="assetBarCode">
  136. <el-input v-model="form.assetBarCode" placeholder="请输入设备条形码" />
  137. </el-form-item>
  138. <el-form-item label="报备人" prop="userId">
  139. <el-input v-model="form.userId" placeholder="请输入报备人" />
  140. </el-form-item>
  141. <el-form-item label="报备时间" prop="reportDate">
  142. <el-date-picker clearable
  143. v-model="form.reportDate"
  144. type="date"
  145. value-format="yyyy-MM-dd"
  146. placeholder="请选择报备时间">
  147. </el-date-picker>
  148. </el-form-item>
  149. <el-form-item label="故障现象" prop="faultPhenomenon">
  150. <el-input v-model="form.faultPhenomenon" type="textarea" placeholder="请输入内容" />
  151. </el-form-item>
  152. <el-form-item label="报备人电话" prop="tel">
  153. <el-input v-model="form.tel" placeholder="请输入报备人电话" />
  154. </el-form-item>
  155. <el-form-item label="处理状态" prop="processState">
  156. <el-select v-model="form.processState" placeholder="请选择处理状态">
  157. <el-option
  158. v-for="dict in dict.type.asset_fault_process_state"
  159. :key="dict.value"
  160. :label="dict.label"
  161. :value="parseInt(dict.value)"
  162. ></el-option>
  163. </el-select>
  164. </el-form-item>
  165. <el-form-item label="处理结果" prop="processResult">
  166. <el-input v-model="form.processResult" type="textarea" placeholder="请输入内容" />
  167. </el-form-item>
  168. </el-form>
  169. <div slot="footer" class="dialog-footer">
  170. <el-button type="primary" @click="submitForm">确 定</el-button>
  171. <el-button @click="cancel">取 消</el-button>
  172. </div>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import { listFault, getFault, delFault, addFault, updateFault } from "@/api/asset/fault";
  178. export default {
  179. name: "Fault",
  180. dicts: ['asset_fault_process_state'],
  181. data() {
  182. return {
  183. // 遮罩层
  184. loading: true,
  185. // 选中数组
  186. ids: [],
  187. // 非单个禁用
  188. single: true,
  189. // 非多个禁用
  190. multiple: true,
  191. // 显示搜索条件
  192. showSearch: true,
  193. // 总条数
  194. total: 0,
  195. // 故障报备表格数据
  196. faultList: [],
  197. // 弹出层标题
  198. title: "",
  199. // 是否显示弹出层
  200. open: false,
  201. // 查询参数
  202. queryParams: {
  203. pageNum: 1,
  204. pageSize: 10,
  205. assetBarCode: null,
  206. userId: null,
  207. reportDate: null,
  208. faultPhenomenon: null,
  209. processState: null,
  210. },
  211. // 表单参数
  212. form: {},
  213. // 表单校验
  214. rules: {
  215. assetBarCode: [
  216. { required: true, message: "设备条形码不能为空", trigger: "blur" }
  217. ],
  218. userId: [
  219. { required: true, message: "报备人不能为空", trigger: "blur" }
  220. ],
  221. reportDate: [
  222. { required: true, message: "报备时间不能为空", trigger: "blur" }
  223. ],
  224. faultPhenomenon: [
  225. { required: true, message: "故障现象不能为空", trigger: "blur" }
  226. ],
  227. tel: [
  228. { required: true, message: "报备人电话不能为空", trigger: "blur" }
  229. ],
  230. processState: [
  231. { required: true, message: "处理状态不能为空", trigger: "change" }
  232. ],
  233. }
  234. };
  235. },
  236. created() {
  237. this.getList();
  238. },
  239. methods: {
  240. /** 查询故障报备列表 */
  241. getList() {
  242. this.loading = true;
  243. listFault(this.queryParams).then(response => {
  244. this.faultList = response.rows;
  245. this.total = response.total;
  246. this.loading = false;
  247. });
  248. },
  249. // 取消按钮
  250. cancel() {
  251. this.open = false;
  252. this.reset();
  253. },
  254. // 表单重置
  255. reset() {
  256. this.form = {
  257. id: null,
  258. assetBarCode: null,
  259. userId: null,
  260. reportDate: null,
  261. faultPhenomenon: null,
  262. tel: null,
  263. processState: null,
  264. processResult: null
  265. };
  266. this.resetForm("form");
  267. },
  268. /** 搜索按钮操作 */
  269. handleQuery() {
  270. this.queryParams.pageNum = 1;
  271. this.getList();
  272. },
  273. /** 重置按钮操作 */
  274. resetQuery() {
  275. this.resetForm("queryForm");
  276. this.handleQuery();
  277. },
  278. // 多选框选中数据
  279. handleSelectionChange(selection) {
  280. this.ids = selection.map(item => item.id)
  281. this.single = selection.length!==1
  282. this.multiple = !selection.length
  283. },
  284. /** 新增按钮操作 */
  285. handleAdd() {
  286. this.reset();
  287. this.open = true;
  288. this.title = "添加故障报备";
  289. },
  290. /** 修改按钮操作 */
  291. handleUpdate(row) {
  292. this.reset();
  293. const id = row.id || this.ids
  294. getFault(id).then(response => {
  295. this.form = response.data;
  296. this.open = true;
  297. this.title = "修改故障报备";
  298. });
  299. },
  300. /** 提交按钮 */
  301. submitForm() {
  302. this.$refs["form"].validate(valid => {
  303. if (valid) {
  304. if (this.form.id != null) {
  305. updateFault(this.form).then(response => {
  306. this.$modal.msgSuccess("修改成功");
  307. this.open = false;
  308. this.getList();
  309. });
  310. } else {
  311. addFault(this.form).then(response => {
  312. this.$modal.msgSuccess("新增成功");
  313. this.open = false;
  314. this.getList();
  315. });
  316. }
  317. }
  318. });
  319. },
  320. /** 删除按钮操作 */
  321. handleDelete(row) {
  322. const ids = row.id || this.ids;
  323. this.$modal.confirm('是否确认删除故障报备编号为"' + ids + '"的数据项?').then(function() {
  324. return delFault(ids);
  325. }).then(() => {
  326. this.getList();
  327. this.$modal.msgSuccess("删除成功");
  328. }).catch(() => {});
  329. },
  330. /** 导出按钮操作 */
  331. handleExport() {
  332. this.download('asset/fault/export', {
  333. ...this.queryParams
  334. }, `fault_${new Date().getTime()}.xlsx`)
  335. }
  336. }
  337. };
  338. </script>