index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-form-item>
  7. <el-date-picker
  8. v-model="date"
  9. :editable="false"
  10. format="yyyy-MM-dd"
  11. value-format="yyyy-MM-dd"
  12. @change="getList"
  13. :clearable="false"
  14. type="date"
  15. placeholder="选择日期"
  16. ></el-date-picker>
  17. </el-form-item>
  18. <el-form-item style="float:right;">
  19. <el-link type="primary" :underline="false" @click="handleAdd">异常申请</el-link>
  20. </el-form-item>
  21. </el-form>
  22. </el-col>
  23. <!--列表-->
  24. <el-table
  25. :data="list"
  26. highlight-current-row
  27. v-loading="listLoading"
  28. :height="tableHeight"
  29. style="width: 100%;"
  30. >
  31. <el-table-column type="index" width="60"></el-table-column>
  32. <el-table-column prop="projectName" label="姓名" width="140" sortable></el-table-column>
  33. <el-table-column prop="ownerCompanyName" label="手机" width="180"></el-table-column>
  34. <el-table-column prop="customCompaniesStr" label="研发"></el-table-column>
  35. <el-table-column prop="manager" label="设计" sortable></el-table-column>
  36. <el-table-column prop="manager" label="办公" sortable></el-table-column>
  37. <el-table-column prop="manager" label="娱乐" sortable></el-table-column>
  38. <el-table-column prop="manager" label="浏览" sortable></el-table-column>
  39. <el-table-column prop="indate" label="总时长" width="180" sortable></el-table-column>
  40. </el-table>
  41. <!--工具条-->
  42. <el-col :span="24" class="toolbar">
  43. <el-pagination
  44. @size-change="handleSizeChange"
  45. @current-change="handleCurrentChange"
  46. :page-sizes="[20 , 50 , 80 , 100]"
  47. :page-size="20"
  48. layout="total, sizes, prev, pager, next"
  49. :total="total"
  50. style="float:right;"
  51. ></el-pagination>
  52. </el-col>
  53. <!--新增界面-->
  54. <el-dialog
  55. title="异常申请列表"
  56. v-if="addFormVisible"
  57. :visible.sync="addFormVisible"
  58. :close-on-click-modal="false"
  59. customClass="customWidth"
  60. >
  61. <el-table
  62. :data="list"
  63. highlight-current-row
  64. v-loading="listLoading"
  65. height="400"
  66. style="width: 100%;"
  67. >
  68. <el-table-column type="index" width="60"></el-table-column>
  69. <el-table-column prop="projectName" label="姓名" width="140" sortable></el-table-column>
  70. <el-table-column prop="indate" label="工作时长" width="100" sortable></el-table-column>
  71. <el-table-column prop="indate" label="异常原因" width="180" sortable></el-table-column>
  72. <el-table-column prop="indate" label="时间" sortable></el-table-column>
  73. </el-table>
  74. <div slot="footer" class="dialog-footer">
  75. <el-button @click.native="addFormVisible = false">取消</el-button>
  76. </div>
  77. </el-dialog>
  78. </section>
  79. </template>
  80. <script>
  81. import util from "../../common/js/util";
  82. export default {
  83. data() {
  84. return {
  85. user: JSON.parse(sessionStorage.getItem("user")),
  86. date: new Date(),
  87. tableHeight: 0,
  88. listLoading: false,
  89. total: 0,
  90. page: 1,
  91. size: 20,
  92. list: [],
  93. addFormVisible: false,
  94. addLoading: false
  95. };
  96. },
  97. methods: {
  98. //分页
  99. handleCurrentChange(val) {
  100. this.page = val;
  101. this.getList();
  102. },
  103. handleSizeChange(val) {
  104. this.size = val;
  105. this.getList();
  106. },
  107. //获取项目列表
  108. getList() {
  109. this.listLoading = true;
  110. this.http.post(
  111. this.port.project.projectList,
  112. {
  113. keyName: "",
  114. pageNum: this.page,
  115. pageSize: this.size
  116. },
  117. res => {
  118. this.listLoading = false;
  119. if (res.code == "ok") {
  120. var list = res.data.list;
  121. for (var i in list) {
  122. var customCompaniesStr = "";
  123. for (var j in list[i].customCompanies) {
  124. if (j == list[i].customCompanies.length - 1) {
  125. customCompaniesStr += list[i].customCompanies[j].companyName;
  126. } else {
  127. customCompaniesStr +=
  128. list[i].customCompanies[j].companyName + "、";
  129. }
  130. }
  131. list[i].customCompaniesStr = customCompaniesStr;
  132. }
  133. this.list = list;
  134. this.total = res.data.total;
  135. } else {
  136. this.$message({
  137. message: res.msg,
  138. type: "error"
  139. });
  140. }
  141. },
  142. error => {
  143. this.listLoading = false;
  144. this.$message({
  145. message: error,
  146. type: "error"
  147. });
  148. }
  149. );
  150. },
  151. //显示新增界面
  152. handleAdd() {
  153. this.getUnusual();
  154. this.addFormVisible = true;
  155. },
  156. // 获取异常列表
  157. getUnusual() {
  158. this.listLoading = true;
  159. this.http.post(
  160. this.port.project.projectList,
  161. {
  162. keyName: "",
  163. pageNum: this.page,
  164. pageSize: this.size
  165. },
  166. res => {
  167. this.listLoading = false;
  168. if (res.code == "ok") {
  169. var list = res.data.list;
  170. for (var i in list) {
  171. var customCompaniesStr = "";
  172. for (var j in list[i].customCompanies) {
  173. if (j == list[i].customCompanies.length - 1) {
  174. customCompaniesStr += list[i].customCompanies[j].companyName;
  175. } else {
  176. customCompaniesStr +=
  177. list[i].customCompanies[j].companyName + "、";
  178. }
  179. }
  180. list[i].customCompaniesStr = customCompaniesStr;
  181. }
  182. this.list = list;
  183. this.total = res.data.total;
  184. } else {
  185. this.$message({
  186. message: res.msg,
  187. type: "error"
  188. });
  189. }
  190. },
  191. error => {
  192. this.listLoading = false;
  193. this.$message({
  194. message: error,
  195. type: "error"
  196. });
  197. }
  198. );
  199. }
  200. },
  201. created() {
  202. let height = window.innerHeight;
  203. this.tableHeight = height - 195;
  204. const that = this;
  205. window.onresize = function temp() {
  206. that.tableHeight = window.innerHeight - 195;
  207. };
  208. },
  209. mounted() {}
  210. };
  211. </script>
  212. <style lang="scss" scoped>
  213. </style>