index.vue 11 KB

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