index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="手机柜id" prop="phoneCabinetId">
  5. <el-input
  6. v-model="queryParams.phoneCabinetId"
  7. placeholder="请输入手机柜id"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="所属人姓名" prop="name">
  14. <el-input
  15. v-model="queryParams.name"
  16. placeholder="请输入所属人姓名"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="格子编号" prop="gridNumber">
  23. <el-input
  24. v-model="queryParams.gridNumber"
  25. placeholder="请输入格子编号"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="格子状态" prop="latticeState">
  32. <el-input
  33. v-model="queryParams.latticeState"
  34. placeholder="请输入格子状态"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button
  48. type="primary"
  49. plain
  50. icon="el-icon-plus"
  51. size="mini"
  52. @click="handleAdd"
  53. v-hasPermi="['phone:grid:add']"
  54. >新增</el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="success"
  59. plain
  60. icon="el-icon-edit"
  61. size="mini"
  62. :disabled="single"
  63. @click="handleUpdate"
  64. v-hasPermi="['phone:grid:edit']"
  65. >修改</el-button>
  66. </el-col>
  67. <el-col :span="1.5">
  68. <el-button
  69. type="danger"
  70. plain
  71. icon="el-icon-delete"
  72. size="mini"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. v-hasPermi="['phone:grid:remove']"
  76. >删除</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="warning"
  81. plain
  82. icon="el-icon-download"
  83. size="mini"
  84. :loading="exportLoading"
  85. @click="handleExport"
  86. v-hasPermi="['phone:grid:export']"
  87. >导出</el-button>
  88. </el-col>
  89. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  90. </el-row>
  91. <el-table v-loading="loading" :data="gridList" @selection-change="handleSelectionChange">
  92. <el-table-column type="selection" width="55" align="center" />
  93. <el-table-column label="主键id" align="center" prop="id" />
  94. <el-table-column label="手机柜id" align="center" prop="phoneCabinetId" />
  95. <el-table-column label="所属人姓名" align="center" prop="name" />
  96. <el-table-column label="格子编号" align="center" prop="gridNumber" />
  97. <el-table-column label="格子状态" align="center" prop="latticeState" />
  98. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  99. <template slot-scope="scope">
  100. <el-button
  101. size="mini"
  102. type="text"
  103. icon="el-icon-edit"
  104. @click="handleUpdate(scope.row)"
  105. v-hasPermi="['phone:grid:edit']"
  106. >修改</el-button>
  107. <el-button
  108. size="mini"
  109. type="text"
  110. icon="el-icon-delete"
  111. @click="handleDelete(scope.row)"
  112. v-hasPermi="['phone:grid:remove']"
  113. >删除</el-button>
  114. </template>
  115. </el-table-column>
  116. </el-table>
  117. <pagination
  118. v-show="total>0"
  119. :total="total"
  120. :page.sync="queryParams.pageNum"
  121. :limit.sync="queryParams.pageSize"
  122. @pagination="getList"
  123. />
  124. <!-- 添加或修改手机柜格子对话框 -->
  125. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  126. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  127. <el-form-item label="手机柜id" prop="phoneCabinetId">
  128. <el-input v-model="form.phoneCabinetId" placeholder="请输入手机柜id" />
  129. </el-form-item>
  130. <el-form-item label="所属人姓名" prop="name">
  131. <el-input v-model="form.name" placeholder="请输入所属人姓名" />
  132. </el-form-item>
  133. <el-form-item label="格子编号" prop="gridNumber">
  134. <el-input v-model="form.gridNumber" placeholder="请输入格子编号" />
  135. </el-form-item>
  136. <el-form-item label="格子状态" prop="latticeState">
  137. <el-input v-model="form.latticeState" placeholder="请输入格子状态" />
  138. </el-form-item>
  139. </el-form>
  140. <div slot="footer" class="dialog-footer">
  141. <el-button type="primary" @click="submitForm">确 定</el-button>
  142. <el-button @click="cancel">取 消</el-button>
  143. </div>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import { listGrid, getGrid, delGrid, addGrid, updateGrid, exportGrid } from "@/api/phone/grid";
  149. export default {
  150. name: "Grid",
  151. data() {
  152. return {
  153. // 遮罩层
  154. loading: true,
  155. // 导出遮罩层
  156. exportLoading: false,
  157. // 选中数组
  158. ids: [],
  159. // 非单个禁用
  160. single: true,
  161. // 非多个禁用
  162. multiple: true,
  163. // 显示搜索条件
  164. showSearch: true,
  165. // 总条数
  166. total: 0,
  167. // 手机柜格子表格数据
  168. gridList: [],
  169. // 弹出层标题
  170. title: "",
  171. // 是否显示弹出层
  172. open: false,
  173. // 查询参数
  174. queryParams: {
  175. pageNum: 1,
  176. pageSize: 10,
  177. phoneCabinetId: null,
  178. name: null,
  179. gridNumber: null,
  180. latticeState: null
  181. },
  182. // 表单参数
  183. form: {},
  184. // 表单校验
  185. rules: {
  186. }
  187. };
  188. },
  189. created() {
  190. this.getList();
  191. },
  192. methods: {
  193. /** 查询手机柜格子列表 */
  194. getList() {
  195. this.loading = true;
  196. listGrid(this.queryParams).then(response => {
  197. this.gridList = response.rows;
  198. this.total = response.total;
  199. this.loading = false;
  200. });
  201. },
  202. // 取消按钮
  203. cancel() {
  204. this.open = false;
  205. this.reset();
  206. },
  207. // 表单重置
  208. reset() {
  209. this.form = {
  210. id: null,
  211. phoneCabinetId: null,
  212. name: null,
  213. gridNumber: null,
  214. latticeState: null
  215. };
  216. this.resetForm("form");
  217. },
  218. /** 搜索按钮操作 */
  219. handleQuery() {
  220. this.queryParams.pageNum = 1;
  221. this.getList();
  222. },
  223. /** 重置按钮操作 */
  224. resetQuery() {
  225. this.resetForm("queryForm");
  226. this.handleQuery();
  227. },
  228. // 多选框选中数据
  229. handleSelectionChange(selection) {
  230. this.ids = selection.map(item => item.id)
  231. this.single = selection.length!==1
  232. this.multiple = !selection.length
  233. },
  234. /** 新增按钮操作 */
  235. handleAdd() {
  236. this.reset();
  237. this.open = true;
  238. this.title = "添加手机柜格子";
  239. },
  240. /** 修改按钮操作 */
  241. handleUpdate(row) {
  242. this.reset();
  243. const id = row.id || this.ids
  244. getGrid(id).then(response => {
  245. this.form = response.data;
  246. this.open = true;
  247. this.title = "修改手机柜格子";
  248. });
  249. },
  250. /** 提交按钮 */
  251. submitForm() {
  252. this.$refs["form"].validate(valid => {
  253. if (valid) {
  254. if (this.form.id != null) {
  255. updateGrid(this.form).then(response => {
  256. this.$modal.msgSuccess("修改成功");
  257. this.open = false;
  258. this.getList();
  259. });
  260. } else {
  261. addGrid(this.form).then(response => {
  262. this.$modal.msgSuccess("新增成功");
  263. this.open = false;
  264. this.getList();
  265. });
  266. }
  267. }
  268. });
  269. },
  270. /** 删除按钮操作 */
  271. handleDelete(row) {
  272. const ids = row.id || this.ids;
  273. this.$modal.confirm('是否确认删除手机柜格子编号为"' + ids + '"的数据项?').then(function() {
  274. return delGrid(ids);
  275. }).then(() => {
  276. this.getList();
  277. this.$modal.msgSuccess("删除成功");
  278. }).catch(() => {});
  279. },
  280. /** 导出按钮操作 */
  281. handleExport() {
  282. const queryParams = this.queryParams;
  283. this.$modal.confirm('是否确认导出所有手机柜格子数据项?').then(() => {
  284. this.exportLoading = true;
  285. return exportGrid(queryParams);
  286. }).then(response => {
  287. this.$download.name(response.msg);
  288. this.exportLoading = false;
  289. }).catch(() => {});
  290. }
  291. }
  292. };
  293. </script>