Commit 21cf3069 authored by shangtx's avatar shangtx

feat(工时列表): 增加项目筛选功能

parent 3f51b6fd
...@@ -40,6 +40,7 @@ module.exports = { ...@@ -40,6 +40,7 @@ module.exports = {
"vue/no-use-v-if-with-v-for": 0, "vue/no-use-v-if-with-v-for": 0,
"vue/html-closing-bracket-newline": 0, "vue/html-closing-bracket-newline": 0,
"vue/no-parsing-error": 0, "vue/no-parsing-error": 0,
"no-console": 0 "no-console": 0,
"vue/max-attributes-per-line": 4
} }
} }
\ No newline at end of file
import {axios} from '@/util/axios/request';
const baseUrl = {
// 项目
project: '/projects',
};
/**
* 可供选择的项目
* @param {*} parameter
*/
export function getSelectableProjects() {
return axios({
url: `${baseUrl.project}/selectable`,
method: 'get'
})
}
...@@ -6,7 +6,10 @@ const baseUrl = { ...@@ -6,7 +6,10 @@ const baseUrl = {
}; };
/**
* 工时列表
* @param {*} parameter
*/
export function getPage(parameter) { export function getPage(parameter) {
return axios({ return axios({
url: `${baseUrl.taskEstimate}/consumed-page`, url: `${baseUrl.taskEstimate}/consumed-page`,
...@@ -14,4 +17,14 @@ export function getPage(parameter) { ...@@ -14,4 +17,14 @@ export function getPage(parameter) {
data: parameter, data: parameter,
useFullLoading: true useFullLoading: true
}) })
}
/**
* 工时辅助信息
*/
export function getAuxiliaryInfo(month) {
return axios({
url: `${baseUrl.taskEstimate}/auxiliary-info/${month}`,
method: 'get'
});
} }
\ No newline at end of file
...@@ -18,6 +18,37 @@ ...@@ -18,6 +18,37 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6">
<a-form-item
label="月份"
:labelCol="{ span: 8 }"
:wrapperCol="{ span: 16 }"
>
<a-month-picker
style="width: 100%"
@change="onMonthChange"
:defaultValue="moment()"
/>
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item
label="项目"
:labelCol="{ span: 8 }"
:wrapperCol="{ span: 16 }"
>
<a-select
show-search
:filter-option="projectFilterOption"
:allowClear="true"
v-model="query.projectId"
:options="projectOptions"
@change="projectChange"
/>
</a-form-item>
</a-col>
</a-row> </a-row>
</div> </div>
</a-form> </a-form>
...@@ -26,16 +57,14 @@ ...@@ -26,16 +57,14 @@
<a-table <a-table
size="middle" size="middle"
@change="sortChange" @change="sortChange"
:columns="columns" :columns="reactiveColumns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="false" :pagination="false"
:rowKey="rowKey" rowKey="rowKey"
:loading="loading" :loading="loading"
bordered bordered
class="task-consume-table"
> >
<!-- <template v-for="">-->
<!-- </template>-->
<div slot="title" slot-scope="data"> <div slot="title" slot-scope="data">
<span class="cust-title"> <span class="cust-title">
<a-icon type="hdd" />工时列表{{ data.none }} <a-icon type="hdd" />工时列表{{ data.none }}
...@@ -63,46 +92,25 @@ ...@@ -63,46 +92,25 @@
:showTotal="$showTotal" :showTotal="$showTotal"
/> />
</div> </div>
<span slot="action" slot-scope="text, record, index">
<a-button
size="small"
style="margin-right: 20px"
@click="changeStatus(record, index)"
:disabled="isEdit"
v-if="!record.disabled"
><span style="font-size: 8px">编辑</span></a-button
>
<a-button
size="small"
style="margin-right: 20px"
@click="changeStatus(record, index)"
v-if="record.disabled"
><span style="font-size: 8px">取消</span></a-button
>
</span>
<span slot="wages" slot-scope="text, record, index" :key="record.id">
<a-input-number
style="width: 200px"
v-if="record.disabled || isEdit"
@change="(e) => handleChange(e, index, 'wages')"
:defaultValue="text"
></a-input-number>
<template v-else>{{ text }} RMB</template>
</span>
</a-table> </a-table>
</div> </div>
</a-card> </a-card>
</template> </template>
<script> <script>
import { getPage } from "@/api/task/task"; import { getPage, getAuxiliaryInfo } from "@/api/task/task";
import { getSelectableProjects } from "@/api/project/project";
import { humpToLine, setOrder } from "@/util/util"; import { humpToLine, setOrder } from "@/util/util";
import moment from "moment";
import _ from "lodash";
const dataSource = []; const dataSource = [];
const columns = [ const columns = [
{ {
title: "姓名", title: "姓名",
dataIndex: "userName", dataIndex: "realName",
width: 80,
customRender: (value, row) => { customRender: (value, row) => {
const obj = { const obj = {
children: value, children: value,
...@@ -112,36 +120,33 @@ const columns = [ ...@@ -112,36 +120,33 @@ const columns = [
return obj; return obj;
}, },
}, },
{ title: "项目", dataIndex: "projectName" }, {
]; title: "项目",
const totalCol = { title: "合计", dataIndex: "total",align: 'right' }; dataIndex: "projectName",
width: 200,
// 1日到28日 customRender: (value, record) => {
for (let i = 1; i <= 28; i++) {
columns.push({
title: i,
dataIndex: `d${i}`,
align: 'right'
});
}
// 29到31日
for (let i = 29; i <= 31; i++) {
columns.push({
title: i,
align: 'right',
dataIndex: `d${i}`,
/* customRender: (value) => {
const obj = { const obj = {
children: value, children: value,
attrs: {}, attrs: {},
}; };
if (record.rowKey.startsWith("total")) {
obj.attrs.style = "font-weight: 600;";
}
return obj; return obj;
}, */ },
}); },
} ];
columns.push(totalCol); const totalCol = {
title: "合计",
dataIndex: "total",
align: "right",
width: 45,
customRender: (text) => ({
children: _.round(text || 0, 1),
attrs: { style: "font-weight: 500;" },
}),
};
export default { export default {
name: "TaskEstimateList", name: "TaskEstimateList",
...@@ -150,11 +155,13 @@ export default { ...@@ -150,11 +155,13 @@ export default {
isFirstLoad: true, isFirstLoad: true,
query: { query: {
userName: "", userName: "",
month: "", projectId: null,
month: moment().format("YYYY-MM"),
sort: "", sort: "",
page: 1, page: 1,
size: 10, size: 10,
}, },
month: null,
dayOfTheMonth: 31, dayOfTheMonth: 31,
total: 0, total: 0,
isEdit: false, isEdit: false,
...@@ -163,12 +170,57 @@ export default { ...@@ -163,12 +170,57 @@ export default {
loading: false, loading: false,
columns: columns, columns: columns,
dataSource: dataSource, dataSource: dataSource,
moment,
fixedColums: [],
restDays: [],
standardConsume: 8,
projectOptions: [],
}; };
}, },
computed: { computed: {
defaultPageSize: function () { defaultPageSize: function () {
return this.$defaultPageSize(); return this.$defaultPageSize();
}, },
reactiveColumns() {
const dateColumns = [];
for (let i = 1; i <= this.dayOfTheMonth; i++) {
dateColumns.push({
title: i,
dataIndex: `d${i}`,
width: 40,
align: "right",
customRender: (text, record) => {
const value = _.round(text || 0, 1);
const obj = {
children: value,
attrs: {
style: "text-align: right;",
},
};
if (record.rowKey.startsWith("total")) {
obj.attrs.style += "font-weight: 500;";
if (!this.restDays.includes(i)) {
if (value > this.standardConsume) {
obj.attrs.style = obj.attrs.style + "color: blue;";
}
if (value < this.standardConsume) {
obj.attrs.style = obj.attrs.style + "color: red;";
}
}
}
if (this.restDays.includes(i)) {
obj.attrs.style = obj.attrs.style + "background: #9aefb8;";
}
return obj;
},
});
}
return columns.concat(dateColumns.concat(totalCol));
},
}, },
methods: { methods: {
search() { search() {
...@@ -177,6 +229,11 @@ export default { ...@@ -177,6 +229,11 @@ export default {
}, },
reset() { reset() {
this.query.userName = ""; this.query.userName = "";
this.query.projectId = null;
this.query.month = moment().format("YYYY-MM");
this.loadData();
},
projectChange() {
this.loadData(); this.loadData();
}, },
pageChange(page) { pageChange(page) {
...@@ -199,6 +256,12 @@ export default { ...@@ -199,6 +256,12 @@ export default {
} }
this.loading = false; this.loading = false;
}); });
getAuxiliaryInfo(this.query.month).then(
({ data: [restDays, standardConsume] }) => {
this.restDays = restDays;
this.standardConsume = standardConsume;
}
);
}, },
sortChange(pagination, filters, sorter) { sortChange(pagination, filters, sorter) {
...@@ -206,16 +269,40 @@ export default { ...@@ -206,16 +269,40 @@ export default {
this.query.order = setOrder(sorter.order); this.query.order = setOrder(sorter.order);
this.loadData(); this.loadData();
}, },
changeBatch() {}, /**
* 筛选项目
onCtDateChange(date, dateString) { */
this.ctDatePicker = date; projectFilterOption(input, option) {
this.query.ctDateBegin = dateString[0]; return (
this.query.ctDateEnd = dateString[1]; option.componentOptions.children[0].text
.toLowerCase()
.indexOf(input.toLowerCase()) >= 0
);
},
/**
* 月份输入框change事件
*/
onMonthChange(date, dateString) {
// 重新查询数据
this.query.page = 1;
this.month = date;
this.query.month = dateString;
this.loadData(); this.loadData();
// 重新计算当月天数
this.dayOfTheMonth = date.daysInMonth();
}, },
}, },
mounted() {}, mounted() {
getSelectableProjects().then(({ data }) => {
if (data && data.length) {
this.projectOptions = data.map((d) => ({
title: d.name,
value: d.id,
}));
}
});
},
activated() { activated() {
if (this.isFirstLoad == true) { if (this.isFirstLoad == true) {
this.loadData(this.defaultPageSize); this.loadData(this.defaultPageSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment