budgetReview.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <section>
  3. <div class="budgetReviewHeader">
  4. <div class="budgetReviewHeader_Form">
  5. <!-- 日期 -->
  6. <div class="budgetReviewHeader_FormItem">
  7. <el-date-picker size="small" v-model="screeningConditionForm.dateRange" :editable="false"
  8. format="yyyy-MM-dd" value-format="yyyy-MM-dd" :clearable="false" :range-separator="'至'"
  9. type="daterange" :start-placeholder="'开始日期'" :end-placeholder="'结束日期'" style="width: 260px"
  10. @change="getList"></el-date-picker>
  11. </div>
  12. <!-- 项目 -->
  13. <div class="budgetReviewHeader_FormItem">
  14. <div class="budgetReviewHeader_FormItemText">项目:</div>
  15. <el-select v-model="screeningConditionForm.projectId" filterable placeholder="请选择项目" clearable
  16. size="small" @change="getList">
  17. <el-option v-for="item in projectList" :key="item.id"
  18. :label="item.projectName + '\u3000' + item.projectCode" :value="item.id">
  19. <span class="selectProRight">{{ item.projectCode }}</span>
  20. <span class="selectProleft">{{ item.projectName }}</span>
  21. </el-option>
  22. </el-select>
  23. </div>
  24. <!-- 审核人 -->
  25. <div class="budgetReviewHeader_FormItem">
  26. <div class="budgetReviewHeader_FormItemText">审核人:</div>
  27. <el-select v-model="screeningConditionForm.submitUserId" filterable placeholder="请选择审核人" clearable
  28. size="small" v-if="user.userNameNeedTranslate != 1" style="width: 130px;" @change="getList">
  29. <el-option v-for="item in usersList" :key="item.id" :label="item.name + '\u3000' + item.jobNumber"
  30. :value="item.id">
  31. <span class="selectProRight">{{ item.jobNumber }}</span>
  32. <span class="selectProleft">{{ item.name }}</span>
  33. </el-option>
  34. </el-select>
  35. <selectCat :size="'small'" :subject="usersList" :subjectId="screeningConditionForm.submitUserId"
  36. :clearable="true" :filterable="true" :searchBoxTop="1" stinction="'1'" @selectCal="selectCal"
  37. v-if="user.userNameNeedTranslate == 1" :widthStr="'130'"></selectCat>
  38. </div>
  39. <!-- 审核状态 -->
  40. <div class="budgetReviewHeader_FormItem">
  41. <div class="budgetReviewHeader_FormItemText">审核状态:</div>
  42. <el-select v-model="screeningConditionForm.status" filterable placeholder="请选择状态" clearable size="small"
  43. style="width: 120px;" @change="getList">
  44. <el-option v-for="item in auditStatus" :key="item.id" :label="item.label" :value="item.id">
  45. </el-option>
  46. </el-select>
  47. </div>
  48. </div>
  49. <div class="budgetReviewHeader_btn">
  50. <el-button type="primary" size="small" @click="exportReport" :loading="exporListLoading">导出</el-button>
  51. </div>
  52. </div>
  53. <!--列表-->
  54. <el-table :data="list" ref="multipleTable" highlight-current-row v-loading="listLoading" :height="tableHeight"
  55. style="width: 100%;">
  56. <el-table-column prop="projectName" :label="'项目名称'" sortable min-width="200px">
  57. <template slot-scope="scope">
  58. <div>
  59. <span>
  60. {{ scope.row.projectName }}
  61. </span>
  62. </div>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="groupName" :label="'分组名称'" sortable min-width="180px">
  66. <template slot-scope="scope">
  67. <div>
  68. <span>
  69. {{ scope.row.groupName }}
  70. </span>
  71. </div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="creator" :label="'提交人'" sortable min-width="120px">
  75. <template slot-scope="scope">
  76. <div>
  77. <span v-if="user.userNameNeedTranslate == '1'">
  78. <ww-open-data type='userName' :openid='scope.row.creator'></ww-open-data>
  79. </span>
  80. <span v-else>
  81. {{ scope.row.creator }}
  82. </span>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="createTime" :label="'提交时间'" sortable min-width="120px">
  87. <template slot-scope="scope">
  88. <div>
  89. <span>
  90. {{ scope.row.createTime }}
  91. </span>
  92. </div>
  93. </template>
  94. </el-table-column>
  95. <el-table-column prop="oldManDay" :label="'变更前预估工时'" sortable min-width="150px">
  96. <template slot-scope="scope">
  97. <div>
  98. <span>
  99. {{ scope.row.oldManDay }}
  100. </span>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column prop="changeManDay" :label="'预估工时变更'" sortable min-width="150px">
  105. <template slot-scope="scope">
  106. <div>
  107. <span>
  108. {{ scope.row.changeManDay }}
  109. </span>
  110. </div>
  111. </template>
  112. </el-table-column>
  113. <el-table-column prop="nowManDay" :label="'变更后预估工时'" sortable min-width="150px">
  114. <template slot-scope="scope">
  115. <div>
  116. <span>
  117. {{ scope.row.nowManDay }}
  118. </span>
  119. </div>
  120. </template>
  121. </el-table-column>
  122. <el-table-column prop="remark" :label="'变更理由'" sortable width="200px">
  123. <template slot-scope="scope">
  124. <div>
  125. <div v-if="scope.row.remark && scope.row.remark.length > 11">
  126. <el-tooltip class="remarkClassItem" effect="dark" :content="scope.row.remark" placement="top">
  127. <div class="remarkClass">{{ scope.row.remark }}</div>
  128. </el-tooltip>
  129. </div>
  130. <div v-else>
  131. {{ scope.row.remark }}
  132. </div>
  133. </div>
  134. </template>
  135. </el-table-column>
  136. <el-table-column prop="status" :label="$t('state.states')" sortable>
  137. <template slot-scope="scope">
  138. <span v-if="scope.row.status == 0" style="color:#DAA520;">{{ '待审核' }}</span>
  139. <span v-else-if="scope.row.status == 1" style="color:#32CD32;">{{ $t('state.alreadyPassed') }}</span>
  140. <span v-else-if="scope.row.status == 2" style="color:#FF0000;">{{ $t('state.rejected') }}</span>
  141. </template>
  142. </el-table-column>
  143. <el-table-column :label="$t('operation')" width="220" fixed="right">
  144. <template slot-scope="scope">
  145. <el-button v-if="scope.row.status == 0" type="primary" :loading="logining" size="small"
  146. @click="review(scope.row.id, 1)">{{ $t('btn.through') }}</el-button>
  147. <el-button v-if="scope.row.status == 0" type="danger" :loading="logining" size="small"
  148. @click="review(scope.row.id, 2)">{{ $t('btn.rejected') }}</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. </section>
  153. </template>
  154. <script>
  155. // 引入自定义组件
  156. import selectCat from "@/components/select.vue"
  157. export default {
  158. components: {
  159. selectCat,
  160. },
  161. data() {
  162. return {
  163. list: [],
  164. tableHeight: 0,
  165. listLoading: false,
  166. defaultExpandAllFlg: false,
  167. exporListLoading: false,
  168. user: JSON.parse(sessionStorage.getItem("user")),
  169. usersList: [],
  170. searchUsersList: [],
  171. projectList: [],
  172. auditStatus: [
  173. { id: 1, label: '待审核' },
  174. { id: 2, label: '审核通过' },
  175. { id: 3, label: '已驳回' }
  176. ],
  177. screeningConditionForm: {
  178. projectId: '',
  179. dateRange: '',
  180. submitUserId: '',
  181. status: ''
  182. }
  183. };
  184. },
  185. filters: {
  186. manHourText(value) {
  187. return value == 0 ? 0 : value + 'h';
  188. }
  189. },
  190. methods: {
  191. review(id,checkType){
  192. this.http.post("/group-budget-review/check", {id:id,checkType:checkType},
  193. res => {
  194. if (res.code == "ok") {
  195. this.$message({
  196. message:"操作成功",
  197. type: "success"
  198. });
  199. this.getList();
  200. } else {
  201. this.$message({
  202. message: res.msg,
  203. type: "error"
  204. });
  205. }
  206. },
  207. error => {
  208. this.$message({
  209. message: error,
  210. type: "error"
  211. });
  212. });
  213. },
  214. //获取待审核的数据列表
  215. getList() {
  216. this.listLoading = true;
  217. const { projectId, dateRange, submitUserId, status } = this.screeningConditionForm;
  218. const params = {
  219. ...(projectId && { projectId }),
  220. ...(dateRange && { startTime: dateRange[0], endTime: dateRange[1] }),
  221. ...(submitUserId && { submitUserId }),
  222. ...(status && { status }),
  223. };
  224. this.http.post("/group-budget-review/list", {
  225. ...params
  226. },
  227. res => {
  228. this.listLoading = false;
  229. if (res.code == "ok") {
  230. this.list = res.data;
  231. } else {
  232. this.$message({
  233. message: res.msg,
  234. type: "error"
  235. });
  236. }
  237. },
  238. error => {
  239. this.listLoading = false;
  240. this.$message({
  241. message: error,
  242. type: "error"
  243. });
  244. });
  245. },
  246. //获取项目列表
  247. getProjectList() {
  248. this.http.post(this.port.project.list, {},
  249. res => {
  250. if (res.code == "ok") {
  251. this.projectList = res.data;
  252. } else {
  253. this.$message({
  254. message: res.msg,
  255. type: "error"
  256. });
  257. }
  258. },
  259. error => {
  260. this.$message({
  261. message: error,
  262. type: "error"
  263. });
  264. });
  265. },
  266. // 获取所有人员
  267. getUsers() {
  268. this.http.post('/user/getSimpleActiveUserList', {},
  269. res => {
  270. if (res.code == "ok") {
  271. this.usersList = res.data;
  272. this.searchUsersList = this.usersList
  273. } else {
  274. this.$message({
  275. message: res.msg,
  276. type: "error"
  277. });
  278. }
  279. },
  280. error => {
  281. this.$message({
  282. message: error,
  283. type: "error"
  284. });
  285. });
  286. },
  287. selectCal(obj) {
  288. console.log(obj, '过来的数据')
  289. if (obj.distinction == 1) {
  290. this.screeningConditionForm.submitUserId = obj.id
  291. this.getList()
  292. }
  293. },
  294. // 获取当月第一天到现在的日期
  295. getNowMonth() {
  296. let date = new Date();
  297. let year = date.getFullYear();
  298. let month = date.getMonth() + 1;
  299. let day = date.getDate();
  300. let now = year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  301. let firstDay = year + '-' + (month < 10 ? '0' + month : month) + '-01';
  302. this.screeningConditionForm.dateRange = [firstDay, now]
  303. },
  304. // 导出
  305. exportReport() {
  306. const { projectId, dateRange, submitUserId, status } = this.screeningConditionForm;
  307. const params = {
  308. ...(projectId && { projectId }),
  309. ...(dateRange && { startTime: dateRange[0], endTime: dateRange[1] }),
  310. ...(submitUserId && { submitUserId }),
  311. ...(status && { status }),
  312. };
  313. this.exporListLoading = true;
  314. this.http.post('/group-budget-review/export', {
  315. ...params
  316. },
  317. res => {
  318. this.exporListLoading = false
  319. if (res.code == "ok") {
  320. var filePath = res.data;
  321. const a = document.createElement('a'); // 创建a标签
  322. a.setAttribute('download', '预估工时审核');// download属性
  323. a.setAttribute('href', filePath);// href链接
  324. a.click(); //自执行点击事件
  325. a.remove();
  326. } else {
  327. this.$message({
  328. message: res.msg,
  329. type: "error"
  330. });
  331. }
  332. },
  333. error => {
  334. this.exporListLoading = false
  335. this.$message({
  336. message: error,
  337. type: "error"
  338. });
  339. });
  340. }
  341. },
  342. created() {
  343. let height = window.innerHeight;
  344. this.tableHeight = height - 125;
  345. const that = this;
  346. window.onresize = function temp() {
  347. that.tableHeight = window.innerHeight - 125;
  348. };
  349. },
  350. mounted() {
  351. this.getNowMonth()
  352. this.getUsers();
  353. this.getProjectList()
  354. this.getList();
  355. }
  356. };
  357. </script>
  358. <style lang="scss" scoped>
  359. .propsbtn {
  360. display: inline-block;
  361. padding-left: 20px;
  362. }
  363. .remarkClass {
  364. overflow: hidden;
  365. text-overflow: ellipsis;
  366. white-space: nowrap;
  367. }
  368. .selectProRight {
  369. float: right;
  370. color: #8492a6;
  371. font-size: 13px;
  372. margin-left: 10px;
  373. }
  374. .selectProleft {
  375. float: left;
  376. }
  377. .budgetReviewHeader {
  378. padding: 10px 20px;
  379. background: #F2F2F2;
  380. display: flex;
  381. justify-content: space-between;
  382. flex-wrap: wrap;
  383. }
  384. .budgetReviewHeader_Form {
  385. display: flex;
  386. .budgetReviewHeader_FormItem {
  387. display: flex;
  388. align-items: center;
  389. margin-right: 20px;
  390. .budgetReviewHeader_FormItemText {
  391. margin-right: 10px;
  392. font-size: 14px;
  393. color: #333;
  394. }
  395. }
  396. }
  397. </style>