index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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="devNo">
  5. <el-input
  6. v-model="queryParams.devNo"
  7. placeholder="请输入位号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="位置" prop="position">
  13. <el-input
  14. v-model="queryParams.position"
  15. placeholder="请输入位置"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="年" prop="planYear">
  21. <el-date-picker
  22. v-model="year"
  23. :clearable="false"
  24. format="yyyy"
  25. placeholder="请选择年份"
  26. type="year"
  27. @change="handleQuery">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="月" prop="planQuarter">
  31. <el-date-picker
  32. v-model="month"
  33. :clearable="false"
  34. format="MM"
  35. placeholder="选择月"
  36. popper-class="picker-date"
  37. type="month"
  38. @change="handleQuery">
  39. </el-date-picker>
  40. </el-form-item>
  41. <el-form-item label="计划名称" prop="planId">
  42. <el-select v-model="queryParams.planId" clearable
  43. @change="handleQuery">
  44. <el-option v-for="item in planList"
  45. :key="item.id"
  46. :label="item.planName"
  47. :value="item.id"/>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  52. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  53. </el-form-item>
  54. </el-form>
  55. <el-row :gutter="10" class="mb8">
  56. <el-col :span="1.5">
  57. <el-button
  58. type="warning"
  59. plain
  60. icon="el-icon-download"
  61. size="mini"
  62. @click="handleExport"
  63. v-hasPermi="['commonuse:earplug:export']"
  64. >导出</el-button>
  65. </el-col>
  66. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  67. </el-row>
  68. <el-table v-loading="loading" :data="earplugList" :height="clientHeight" @selection-change="handleSelectionChange" border>
  69. <el-table-column type="selection" width="55" align="center" />
  70. <el-table-column label="位号" align="center" prop="devNo" />
  71. <el-table-column label="位置" align="center" prop="position" />
  72. <el-table-column label="外观情况" align="center" prop="appearance" />
  73. <el-table-column label="标识清晰度" align="center" prop="identificationClarity">
  74. <template slot-scope="scope">
  75. <dict-tag :options="dict.type.inspection_status" :value="scope.row.identificationClarity"/>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="耳塞内分配器数量是否充足" align="center" prop="adequacyOrNot">
  79. <template slot-scope="scope">
  80. <dict-tag :options="dict.type.inspection_status" :value="scope.row.adequacyOrNot"/>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="确认人" align="center" prop="confirmed" />
  84. <el-table-column label="备注" align="center" prop="remarks" />
  85. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  86. <template slot-scope="scope">
  87. <el-button
  88. icon="el-icon-picture-outline"
  89. size="mini"
  90. type="text"
  91. @click="openFileDialog(scope.row)"
  92. >附件
  93. </el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <el-dialog :close-on-click-modal="false":visible.sync="file.open" append-to-body title="附件详情" width="50%">
  98. <el-tabs v-model="tabName" :stretch="true" type="border-card">
  99. <el-tab-pane label="常规附件" name="a">
  100. <el-empty v-if="file.files.length==0" description="如你所见,这里什么都没有"></el-empty>
  101. <el-image v-for="url in file.files" v-else :key="url" :src="url"></el-image>
  102. </el-tab-pane>
  103. <el-tab-pane label="异常附件" name="b">
  104. <el-empty v-if="file.issuesFiles.length==0" description="如你所见,这里什么都没有"></el-empty>
  105. <el-image v-for="url in file.issuesFiles" v-else :key="url" :src="url"></el-image>
  106. </el-tab-pane>
  107. <el-tab-pane label="异常整改后附件" name="c">
  108. <el-empty v-if="file.repairFile.length==0" description="如你所见,这里什么都没有"></el-empty>
  109. <el-image v-for="url in file.repairFile" v-else :key="url" :src="url"></el-image>
  110. </el-tab-pane>
  111. </el-tabs>
  112. </el-dialog>
  113. <pagination
  114. v-show="total>0"
  115. :total="total"
  116. :page.sync="queryParams.pageNum"
  117. :limit.sync="queryParams.pageSize"
  118. @pagination="getList"
  119. />
  120. </div>
  121. </template>
  122. <script>
  123. import { listEarplug, getEarplug, delEarplug, addEarplug, updateEarplug } from "@/api/patrol/commonuse/earplug";
  124. import {listAllPlan} from "@/api/patrol/patrol/plan";
  125. export default {
  126. name: "Earplug",
  127. dicts: ['inspection_status'],
  128. data() {
  129. return {
  130. tabName: 'a',
  131. planList: [],
  132. file: {
  133. open: false,
  134. issuesFiles: [],
  135. repairFile: [],
  136. files: []
  137. },
  138. month: new Date(),
  139. year: new Date(),
  140. // 遮罩层
  141. loading: true,
  142. // 选中数组
  143. ids: [],
  144. // 非单个禁用
  145. single: true,
  146. // 非多个禁用
  147. multiple: true,
  148. // 显示搜索条件
  149. showSearch: false,
  150. // 页面高度
  151. clientHeight: 300,
  152. // 总条数
  153. total: 0,
  154. // 耳塞分配器检查记录表格数据
  155. earplugList: [],
  156. // 弹出层标题
  157. title: "",
  158. // 是否显示弹出层
  159. open: false,
  160. // 查询参数
  161. queryParams: {
  162. pageNum: 1,
  163. pageSize: 20,
  164. id: null,
  165. devNo: null,
  166. position: null,
  167. appearance: null,
  168. identificationClarity: null,
  169. adequacyOrNot: null,
  170. confirmed: null,
  171. remarks: null,
  172. checkStatus: null,
  173. checkDate: null,
  174. month: null,
  175. year: null,
  176. createrCode: null,
  177. createdate: null,
  178. updaterCode: null,
  179. updatedate: null,
  180. deptId: null,
  181. planId: null,
  182. problemFileUrl: null,
  183. fileUrl: null,
  184. issuesStatus: null,
  185. issuesFlag: null,
  186. repairFile: null
  187. },
  188. // 表单参数
  189. form: {},
  190. // 表单校验
  191. rules: {
  192. }
  193. };
  194. },
  195. created() {
  196. if (this.$route.query.year && this.$route.query.month) {
  197. this.year.setFullYear(this.$route.query.year, this.$route.query.month, 1);
  198. this.month.setMonth(this.$route.query.month, 1);
  199. }
  200. if (this.$route.query.planId) {
  201. this.queryParams.planId = parseInt(this.$route.query.planId)
  202. }
  203. if (this.$route.query.id) {
  204. this.queryParams.id = parseInt(this.$route.query.id)
  205. this.queryParams.issuesFlag = '1';
  206. }
  207. //设置表格高度对应屏幕高度
  208. this.$nextTick(() => {
  209. this.clientHeight = document.body.clientHeight - 270
  210. });
  211. if (!this.queryParams.id) {
  212. let query = {planQuarter: this.month.getMonth() + 1, planYear: this.year.getFullYear(), patrolType: '19'}
  213. listAllPlan(query).then(res => {
  214. this.planList = res.data;
  215. if (res.data.length > 0) {
  216. this.queryParams.planId = res.data[0].id;
  217. }
  218. this.getList();
  219. })
  220. }else{
  221. this.getList();
  222. }
  223. },
  224. methods: {
  225. openFileDialog(row) {
  226. this.tabName = 'a'
  227. this.file.issuesFiles = []
  228. this.file.files = []
  229. this.file.repairFile = []
  230. this.file.open = true;
  231. if (row.problemFileUrl)
  232. this.file.issuesFiles = row.problemFileUrl.split(',');
  233. if (row.fileUrl)
  234. this.file.files = row.fileUrl.split(',');
  235. if (row.repairFile)
  236. this.file.repairFile = row.repairFile.split(',');
  237. },
  238. getPlanList() {
  239. let query = {planQuarter: this.month.getMonth() + 1, planYear: this.year.getFullYear(), patrolType: '19'}
  240. listAllPlan(query).then(res => {
  241. this.planList = res.data;
  242. })
  243. },
  244. /** 查询耳塞分配器检查记录列表 */
  245. getList() {
  246. this.loading = true;
  247. if (!this.queryParams.id) {
  248. this.queryParams.month = this.month.getMonth() + 1;
  249. this.queryParams.year = this.year.getFullYear();
  250. }
  251. listEarplug(this.queryParams).then(response => {
  252. this.earplugList = response.rows;
  253. this.total = response.total;
  254. this.loading = false;
  255. });
  256. },
  257. // 取消按钮
  258. cancel() {
  259. this.open = false;
  260. this.reset();
  261. },
  262. // 表单重置
  263. reset() {
  264. this.form = {
  265. id: null,
  266. devNo: null,
  267. position: null,
  268. appearance: null,
  269. identificationClarity: null,
  270. adequacyOrNot: null,
  271. confirmed: null,
  272. remarks: null,
  273. checkStatus: null,
  274. checkDate: null,
  275. month: null,
  276. year: null,
  277. delFlag: null,
  278. createrCode: null,
  279. createdate: null,
  280. updaterCode: null,
  281. updatedate: null,
  282. deptId: null,
  283. planId: null,
  284. problemFileUrl: null,
  285. fileUrl: null,
  286. issuesStatus: null,
  287. issuesFlag: null,
  288. repairFile: null
  289. };
  290. this.resetForm("form");
  291. },
  292. /** 搜索按钮操作 */
  293. handleQuery() {
  294. this.queryParams.pageNum = 1;
  295. this.getList();
  296. this.getPlanList();
  297. },
  298. /** 重置按钮操作 */
  299. resetQuery() {
  300. this.resetForm("queryForm");
  301. this.handleQuery();
  302. },
  303. // 多选框选中数据
  304. handleSelectionChange(selection) {
  305. this.ids = selection.map(item => item.id)
  306. this.single = selection.length!==1
  307. this.multiple = !selection.length
  308. },
  309. /** 新增按钮操作 */
  310. handleAdd() {
  311. this.reset();
  312. this.open = true;
  313. this.title = "添加耳塞分配器检查记录";
  314. },
  315. /** 修改按钮操作 */
  316. handleUpdate(row) {
  317. this.reset();
  318. const id = row.id || this.ids
  319. getEarplug(id).then(response => {
  320. this.form = response.data;
  321. this.open = true;
  322. this.title = "修改耳塞分配器检查记录";
  323. });
  324. },
  325. /** 提交按钮 */
  326. submitForm() {
  327. this.$refs["form"].validate(valid => {
  328. if (valid) {
  329. if (this.form.id != null) {
  330. updateEarplug(this.form).then(response => {
  331. this.msgSuccess("修改成功");
  332. this.open = false;
  333. this.getList();
  334. });
  335. } else {
  336. addEarplug(this.form).then(response => {
  337. this.msgSuccess("新增成功");
  338. this.open = false;
  339. this.getList();
  340. });
  341. }
  342. }
  343. });
  344. },
  345. /** 删除按钮操作 */
  346. handleDelete(row) {
  347. const ids = row.id || this.ids;
  348. this.$confirm('是否确认删除耳塞分配器检查记录编号为"' + ids + '"的数据项?').then(function() {
  349. return delEarplug(ids);
  350. }).then(() => {
  351. this.getList();
  352. this.msgSuccess("删除成功");
  353. }).catch(() => {});
  354. },
  355. /** 导出按钮操作 */
  356. handleExport() {
  357. this.download2('commonuse/earplug/export', {
  358. ...this.queryParams
  359. }, `earplug_${new Date().getTime()}.xlsx`)
  360. }
  361. }
  362. };
  363. </script>