workShiftInfo-list.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div>
  3. <el-breadcrumb separator=">">
  4. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  5. <el-breadcrumb-item>
  6. <a href="#">基础信息</a>
  7. </el-breadcrumb-item>
  8. <el-breadcrumb-item>
  9. <a href="/workShiftInfo">班次管理</a>
  10. </el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <el-divider></el-divider>
  13. <!--
  14. 要resetFields起作用,必须配置:model和prop
  15. -->
  16. <el-form ref="queryForm" :model="queryModel" inline class="demo-form-inline">
  17. <el-form-item label="班次名称" prop="name">
  18. <el-input type="text" size="mini" v-model="queryModel.name"></el-input>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button
  22. type="primary"
  23. size="mini"
  24. icon="ios-search"
  25. @click="changePage(1)"
  26. :loading="loading"
  27. >查询</el-button>&nbsp;
  28. <el-button
  29. type="info"
  30. size="mini"
  31. style="margin-left: 8px"
  32. @click="handleReset('queryForm')"
  33. >重置</el-button>&nbsp;
  34. </el-form-item>
  35. </el-form>
  36. <el-divider></el-divider>
  37. <el-row class="button-group">
  38. <el-button type="primary" size="small" plain icon="el-icon-circle-plus" @click="handleAdd">新增</el-button>
  39. <el-button
  40. type="primary"
  41. size="small"
  42. plain
  43. icon="el-icon-remove"
  44. :disabled="multipleSelection.length==0"
  45. @click="handleBatchDelete"
  46. >删除选中项</el-button>
  47. </el-row>
  48. <el-table
  49. ref="formTable"
  50. :data="tableData"
  51. v-loading="loading"
  52. :element-loading-text="loadingText"
  53. stripe
  54. :height="tableHeight"
  55. @selection-change="handleSelectionChange"
  56. >
  57. <el-table-column type="selection" width="55"></el-table-column>
  58. <el-table-column prop="number" label="班次编号" width="80"></el-table-column>
  59. <el-table-column prop="name" label="班次名称" width="150"></el-table-column>
  60. <el-table-column prop="days" label="天数" width="100" ></el-table-column>
  61. <el-table-column prop="workTime" label="上班时间" width="120"></el-table-column>
  62. <el-table-column prop="workStartTime" label="上班考勤时段" width="150">
  63. <template slot-scope="{row}">
  64. {{row.workStartTime}}-{{row.workEndTime}}
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="closingTime" label="下班时间" width="120"></el-table-column>
  68. <el-table-column prop="closingStartTime" label="下班考勤时段" width="150">
  69. <template slot-scope="{row}">
  70. {{row.closingStartTime}}-{{row.closingEndTime}}
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="companyList" label="关联部门" width="200">
  74. <template slot-scope="{row}">
  75. <div v-for="item in row.companyList" v-bind:key="item.id">
  76. {{item.name}}
  77. </div>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作" width="150" fixed="right">
  81. <template slot-scope="{row}">
  82. <el-row>
  83. <el-col :span="8">
  84. <el-link type="primary" @click="handleEdit(row)">编辑</el-link>
  85. </el-col>
  86. <el-col :span="8">
  87. <el-link type="danger" @click="handleDelete(row)">删除</el-link>
  88. </el-col>
  89. </el-row>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <el-pagination
  94. :current-page.sync="pageIndex"
  95. :total="totalElements"
  96. :page-sizes="pageSizeList"
  97. @current-change="changePage"
  98. @size-change="pageSizeChange"
  99. layout="total, sizes, prev, pager, next, jumper"
  100. ></el-pagination>
  101. <workShiftInfo-detail
  102. v-if="showModal"
  103. :businessKey="businessKey"
  104. :title="modalTitle"
  105. :companyResult="companyResult"
  106. @close="onDetailModalClose"
  107. ></workShiftInfo-detail>
  108. </div>
  109. </template>
  110. <script>
  111. import Constant from "@/constant";
  112. import workShiftInfoDetail from "./workShiftInfo-detail";
  113. import workShiftInfoApi from "@/api/base/workShiftInfo";
  114. import pageUtil from "@/utils/page";
  115. import NProgress from "nprogress"; // progress bar
  116. import "nprogress/nprogress.css"; // progress bar style
  117. export default {
  118. name: 'BaseWorkShiftInfoList',
  119. data() {
  120. var self = this;
  121. return {
  122. queryModel: {
  123. name:""
  124. },
  125. loading: false,
  126. loadingText: "加载中",
  127. tableData: [],
  128. pageIndex: 1,
  129. pageSize: 10,
  130. totalPages: 0,
  131. totalElements: 0,
  132. field: "",
  133. direction: "",
  134. pageSizeList: [10, 20, 30],
  135. multipleSelection: [],
  136. showModal: false,
  137. modalTitle: "",
  138. businessKey: "",
  139. companyResult: [],
  140. tableHeight: 400,
  141. dialogVisible: false,
  142. treeData: [],
  143. props: {
  144. // 配置项(必选)
  145. value: "id",
  146. label: "name",
  147. children: "children"
  148. },
  149. };
  150. },
  151. created() {
  152. },
  153. methods: {
  154. indexMethod(index) {
  155. return (this.pageIndex - 1) * this.pageSize + (index + 1);
  156. },
  157. changePage(pageIndex) {
  158. var self = this;
  159. self.loading = true;
  160. self.loadingText = "加载中...";
  161. self.pageIndex = pageIndex;
  162. var formData = new FormData();
  163. formData.append("pageIndex", self.pageIndex);
  164. formData.append("pageSize", self.pageSize);
  165. formData.append("name", self.queryModel.name);
  166. workShiftInfoApi
  167. .pageList(formData)
  168. .then(function(response) {
  169. self.loading = false;
  170. var jsonData = response.data;
  171. if(jsonData.result) {
  172. var page = jsonData.data;
  173. self.tableData = page.data;
  174. self.totalPages = page.totalPages;
  175. self.totalElements = page.recordsTotal;
  176. }
  177. else{
  178. self.$message.warning(jsonData.message + "");
  179. }
  180. })
  181. .catch(error => {
  182. self.loading = false;
  183. });
  184. },
  185. pageSizeChange(pageSize) {
  186. this.pageSize = pageSize;
  187. },
  188. handleSelectionChange(val) {
  189. this.multipleSelection = val;
  190. },
  191. handleReset(name) {
  192. this.$refs[name].resetFields();
  193. },
  194. handleAdd() {
  195. this.modalTitle = "新增";
  196. this.businessKey = "";
  197. this.showModal = true;
  198. },
  199. handleEdit(record) {
  200. this.modalTitle = "编辑";
  201. this.businessKey = record.id;
  202. this.showModal = true;
  203. },
  204. handleDelete(record) {
  205. var self = this;
  206. self
  207. .$confirm("是否确认删除?", "提示", {
  208. confirmButtonText: "确定",
  209. cancelButtonText: "取消",
  210. type: "warning"
  211. })
  212. .then(() => {
  213. workShiftInfoApi.remove(record.id).then(function(response) {
  214. var jsonData = response.data;
  215. if (jsonData.result) {
  216. // var index = self.tableData.indexOf(record);
  217. // self.tableData.splice(index, 1);
  218. self.changePage(self.pageIndex);
  219. self.$message({
  220. type: "success",
  221. message: "删除成功!"
  222. });
  223. }
  224. });
  225. });
  226. },
  227. handleBatchDelete() {
  228. var self = this;
  229. var idList = this.multipleSelection.map(record => {
  230. return record.id;
  231. });
  232. this.$confirm("是否确认删除选中项?", "提示", {
  233. confirmButtonText: "确定",
  234. cancelButtonText: "取消",
  235. type: "warning"
  236. }).then(() => {
  237. workShiftInfoApi.batchRemove(idList).then(function(response) {
  238. var jsonData = response.data;
  239. if (jsonData.result) {
  240. self.changePage(self.pageIndex);
  241. self.$message({
  242. type: "success",
  243. message: "删除成功!"
  244. });
  245. }
  246. });
  247. });
  248. },
  249. onDetailModalClose(refreshed) {
  250. //保存成功后回调
  251. this.showModal = false;
  252. this.showDeviceModal = false;
  253. if (refreshed) {
  254. this.changePage(this.pageIndex);
  255. }
  256. },
  257. },
  258. mounted: function() {
  259. this.changePage(1);
  260. },
  261. components: {
  262. "workShiftInfo-detail": workShiftInfoDetail,
  263. }
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. .el-breadcrumb {
  268. margin: 10px;
  269. line-height: 20px;
  270. }
  271. .el-divider {
  272. margin: 5px 0;
  273. }
  274. .demo-form-inline {
  275. margin-left: 10px;
  276. text-align: left;
  277. }
  278. .button-group {
  279. margin-left: 10px;
  280. text-align: left;
  281. }
  282. </style>