123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- <template>
- <div>
- <el-breadcrumb separator=">">
- <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
- <el-breadcrumb-item>
- <a href="#">系统管理</a>
- </el-breadcrumb-item>
- <el-breadcrumb-item>
- <a href="/workPersonScheduling">人员排班管理</a>
- </el-breadcrumb-item>
- </el-breadcrumb>
- <el-divider></el-divider>
- <!--
- 要resetFields起作用,必须配置:model和prop
- -->
- <el-form
- ref="queryForm"
- :model="queryModel"
- :rules="ruleValidate"
- inline
- class="demo-form-inline"
- >
- <el-form-item label="安排日期" prop="queryMonth">
- <el-date-picker
- v-model="queryModel.queryMonth"
- size="mini"
- type="month"
- value-format="yyyy-MM"
- placeholder="选择月"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item label="部门" prop="companyId">
- <el-select-tree
- size="mini"
- :props="props"
- :options="companyResult"
- v-model="queryModel.companyId"
- height="200"
- ></el-select-tree
- >
- <el-checkbox v-model="queryModel.subordinate"
- >是否包含下级单位</el-checkbox
- >
- </el-form-item>
- <el-form-item label="姓名" prop="personName">
- <el-input
- type="text"
- size="mini"
- v-model="queryModel.personName"
- style="width: 100px"
- ></el-input>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- size="mini"
- icon="ios-search"
- @click="handleQuery('queryForm')"
- :loading="loading"
- >查询</el-button
- >
- <el-button
- type="info"
- size="mini"
- style="margin-left: 8px"
- @click="handleReset('queryForm')"
- >重置</el-button
- >
- </el-form-item>
- </el-form>
- <el-divider></el-divider>
- <el-row class="button-group">
- <el-button
- type="primary"
- size="small"
- plain
- icon="el-icon-circle-plus"
- @click="handleChange"
- >自动排班</el-button
- >
- </el-row>
- <el-table
- :data="tableData"
- v-loading="loading"
- ref="formTable"
- :height="tableHeight"
- stripe
- @sort-change="sortChange"
- @selection-change="handleSelectionChange"
- >
- <el-table-column type="selection" width="55"></el-table-column>
- <el-table-column
- type="index"
- label="序号"
- :index="indexMethod"
- width="50"
- ></el-table-column>
- <el-table-column
- prop="companyName"
- label="部门"
- width="90"
- ></el-table-column>
- <el-table-column prop="id" label="编号" width="90"></el-table-column>
- <el-table-column prop="name" label="名称" width="150"></el-table-column>
- <template v-for="col in dayList">
- <el-table-column
- :label="col.day + ''"
- :prop="col.id + ''"
- :key="col.id + ''"
- width="100px"
- >
- <template slot-scope="{ row }">
- <div style="display: flex; flex-direction: column">
- <template v-for="(item, index) in row.personNumberMap[col.day]">
- <div
- v-html="showItem(item)"
- :key="index"
- v-on:click="
- changeWork(row.companyId, row.id, row.name, col.day)
- "
- style="white-space: pre-wrap; cursor: pointer"
- ></div>
- </template>
- </div>
- </template>
- </el-table-column>
- </template>
- </el-table>
- <el-pagination
- :current-page.sync="pageIndex"
- :total="totalElements"
- :page-sizes="pageSizeList"
- @current-change="changePage"
- @size-change="pageSizeChange"
- layout="total, sizes, prev, pager, next, jumper"
- ></el-pagination>
- <workPersonScheduling-detail
- v-if="showModal"
- :businessKey="businessKey"
- :title="modalTitle"
- @close="onDetailModalClose"
- ></workPersonScheduling-detail>
- <workPersonScheduling-change
- v-if="showChangeModal"
- :businessKey="businessKey"
- :title="modalTitle"
- @close="onDetailModalClose"
- ></workPersonScheduling-change>
- <!-- 批量解绑设备 -->
- <el-dialog
- title="调班"
- :visible.sync="batchChangeWork"
- :modal-append-to-body="false"
- style="text-align: left"
- :close-on-click-modal="false"
- >
- <el-form label-width="150px" v-loading="changeWorkDisabled">
- <el-form-item label="用户" prop="changeUser">
- <el-input
- type="text"
- v-model="changeUser"
- disabled
- style="width: 200px"
- ></el-input>
- </el-form-item>
- <el-form-item label="部门" prop="changeCompanyId">
- <el-select-tree
- :props="props"
- :options="companyResult"
- v-model="changeCompanyId"
- height="200"
- ></el-select-tree>
- </el-form-item>
- <el-form-item label="班次" prop="changeShiftId">
- <el-select
- v-model="changeShiftId"
- filterable
- multiple
- placeholder="请选择"
- >
- <el-option
- v-for="shift in shiftData"
- :key="shift.id"
- :label="shift.name"
- :value="shift.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="closeBatchChangeWork">关 闭</el-button>
- <el-button type="primary" @click="handleBatchChangeWork"
- >确 定</el-button
- >
- </div>
- </el-dialog>
- <!-- 批量解绑设备end -->
- </div>
- </template>
- <script>
- import Constant from "@/constant";
- import WorkPersonSchedulingDetail from "./workPersonScheduling-detail";
- import WorkPersonSchedulingChange from "./workPersonScheduling-change";
- import workPersonSchedulingApi from "@/api/base/workPersonScheduling";
- import workShiftInfoApi from "@/api/base/workShiftInfo";
- import companyInfoApi from "@/api/base/companyInfo";
- import pageUtil from "@/utils/page";
- import SelectTree from "@/components/SelectTree";
- import NProgress from "nprogress"; // progress bar
- import "nprogress/nprogress.css"; // progress bar style
- export default {
- name: "BaseWorkPersonSchedulingList",
- data() {
- var self = this;
- return {
- ruleValidate: {
- companyId: [{ required: true, message: "不能为空", trigger: "blur" }],
- queryMonth: [{ required: true, message: "请选择", trigger: "blur" }],
- },
- queryModel: {
- personName: "",
- queryMonth: "",
- companyId: "",
- subordinate: false,
- },
- loading: false,
- tableData: [],
- pageIndex: 1,
- pageSize: 10,
- totalPages: 0,
- totalElements: 0,
- field: "",
- direction: "",
- pageSizeList: [10, 20, 30],
- multipleSelection: [],
- showModal: false,
- modalTitle: "",
- businessKey: "",
- treeData: [],
- props: {
- // 配置项(必选)
- value: "id",
- label: "name",
- children: "children",
- },
- companyResult: [],
- dayList: [],
- tableHeight: 300,
- showChangeModal: false,
- batchChangeWork: false,
- changePersonId: "",
- changeDay: "",
- changeCompanyId: "",
- shiftData: [],
- changeShiftId: [],
- changeWorkDisabled: false,
- changeUser: "",
- };
- },
- created() {
- var self = this;
- companyInfoApi.treeList().then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- if (jsonData.data != null && jsonData.data != "") {
- self.companyResult = jsonData.data;
- }
- }
- });
- },
- watch: {
- changeCompanyId: function (val, oldval) {
- if (val != null && val != "") {
- this.queryShiftInfo(val);
- }
- },
- },
- methods: {
- handleQuery() {
- var self = this;
- this.$refs["queryForm"].validate((valid) => {
- if (valid) {
- self.changePage(1);
- }
- });
- },
- showItem(item) {
- var str = item;
- if (item == null || item == "") {
- str = " ";
- }
- return str;
- },
- indexMethod(index) {
- return (this.pageIndex - 1) * this.pageSize + (index + 1);
- },
- changePage(pageIndex) {
- var self = this;
- self.loading = true;
- self.pageIndex = pageIndex;
- var formData = new FormData();
- formData.append("pageIndex", self.pageIndex);
- formData.append("pageSize", self.pageSize);
- formData.append("personName", self.queryModel.personName);
- formData.append("queryMonth", self.queryModel.queryMonth);
- formData.append("companyId", self.queryModel.companyId);
- formData.append("subordinate", self.queryModel.subordinate);
- if (this.field != null) {
- formData.append("field", this.field);
- }
- if (this.direction != null) {
- formData.append("direction", this.direction);
- }
- workPersonSchedulingApi
- .findScheduling(formData)
- .then(function (response) {
- self.loading = false;
- var jsonData = response.data;
- self.tableData = jsonData.personList;
- self.totalPages = jsonData.totalPage;
- self.totalElements = jsonData.recordsTotal;
- self.dayList = jsonData.dayList;
- setTimeout(() => {
- console.log(self.$refs.formTable.$el.offsetTop);
- self.tableHeight = pageUtil.autoAdjustHeight(
- self.$refs.formTable.$el
- );
- }, 1000);
- })
- .catch((error) => {
- self.loading = false;
- // self.$message.error(error + "");
- });
- },
- pageSizeChange(pageSize) {
- this.pageSize = pageSize;
- this.$nextTick(() => {
- this.changePage(this.pageIndex);
- });
- },
- sortChange(data) {
- this.field = data.column.field;
- this.direction = data.order;
- this.changePage(this.pageIndex);
- },
- handleSelectionChange(val) {
- this.multipleSelection = val;
- },
- handleReset(name) {
- this.$refs[name].resetFields();
- },
- handleChange() {
- this.modalTitle = "自动排班";
- this.businessKey = "";
- this.showChangeModal = true;
- },
- onDetailModalClose(refreshed) {
- //保存成功后回调
- this.showModal = false;
- this.showChangeModal = false;
- if (refreshed) {
- this.handleQuery();
- }
- },
- changeWork(companyId, personId, personName, day) {
- var self = this;
- self.changePersonId = personId;
- self.changeDay = day;
- self.changeUser = personName + ",调班日期:" + day + "日";
- self.changeCompanyId = companyId;
- var formData = new FormData();
- formData.append("queryMonth", self.queryModel.queryMonth);
- formData.append("day", day);
- formData.append("personId", personId);
- workPersonSchedulingApi
- .findWPSByParameter(formData)
- .then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- var shiftIds = jsonData.data.shiftIds;
- if (shiftIds != null) {
- self.changeShiftId = shiftIds.split(",");
- }
- } else {
- self.$message({
- showClose: true,
- dangerouslyUseHTMLString: true,
- message: jsonData.message,
- });
- }
- });
- this.batchChangeWork = true;
- },
- handleBatchChangeWork() {
- var self = this;
- var formData = new FormData();
- formData.append("queryMonth", self.queryModel.queryMonth);
- formData.append("day", self.changeDay);
- formData.append("personId", self.changePersonId);
- formData.append("shiftId", self.changeShiftId);
- workPersonSchedulingApi
- .changePersonShift(formData)
- .then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- self.changeDay = "";
- self.changePersonId = "";
- self.changeShiftId = "";
- self.changeCompanyId = "";
- self.changePage(1);
- self.batchChangeWork = false;
- } else {
- self.$message({
- showClose: true,
- dangerouslyUseHTMLString: true,
- message: jsonData.message,
- });
- }
- });
- },
- closeBatchChangeWork() {
- this.changePersonId = "";
- this.changeDay = "";
- this.batchChangeWork = false;
- },
- queryShiftInfo(companyId) {
- var self = this;
- var formData = new FormData();
- formData.append("companyId", companyId);
- workShiftInfoApi.shiftList(formData).then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- if (jsonData.data != null && jsonData.data != "") {
- self.shiftData = jsonData.data;
- }
- }
- });
- },
- },
- mounted: function () {
- //this.changePage(1);
- },
- components: {
- "workPersonScheduling-detail": WorkPersonSchedulingDetail,
- "workPersonScheduling-change": WorkPersonSchedulingChange,
- "el-select-tree": SelectTree,
- },
- };
- </script>
- <style lang="scss" scoped>
- .el-breadcrumb {
- margin: 10px;
- line-height: 20px;
- }
- .el-divider {
- margin: 5px 0;
- }
- .demo-form-inline {
- margin-left: 10px;
- text-align: left;
- }
- .button-group {
- margin-left: 10px;
- text-align: left;
- }
- </style>
|