|
|
@@ -0,0 +1,474 @@
|
|
|
+<template>
|
|
|
+ <basic-container>
|
|
|
+ <avue-crud :option="option"
|
|
|
+ v-model:search="search"
|
|
|
+ v-model:page="page"
|
|
|
+ v-model="form"
|
|
|
+ :table-loading="loading"
|
|
|
+ :data="data"
|
|
|
+ :permission="permissionList"
|
|
|
+ :before-open="beforeOpen"
|
|
|
+ ref="crud"
|
|
|
+ @row-update="rowUpdate"
|
|
|
+ @row-save="rowSave"
|
|
|
+ @row-del="rowDel"
|
|
|
+ @search-change="searchChange"
|
|
|
+ @search-reset="searchReset"
|
|
|
+ @selection-change="selectionChange"
|
|
|
+ @current-change="currentChange"
|
|
|
+ @size-change="sizeChange"
|
|
|
+ @refresh-change="refreshChange"
|
|
|
+ @on-load="onLoad">
|
|
|
+ <template #menu-left>
|
|
|
+ <el-button type="danger"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ plain
|
|
|
+ v-if="permission.process_delete"
|
|
|
+ @click="handleDelete">删 除
|
|
|
+ </el-button>
|
|
|
+ <el-button type="warning"
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ @click="handleExport">导 出
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #details-form>
|
|
|
+ <view style="margin:0 20px">
|
|
|
+ <avue-crud :option="optionSub" ref="detailCrud"
|
|
|
+ :data="form.details">
|
|
|
+ <template #menu-left>
|
|
|
+ <h2>追溯要求</h2>
|
|
|
+
|
|
|
+ <el-button type="primary"
|
|
|
+ :size="size"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ v-if="optionSub.menu"
|
|
|
+ @click="$refs.detailCrud.rowCellAdd()">新增</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #menu="{index,size}">
|
|
|
+ <el-popconfirm title="确认删除数据么?" @confirm="delDetail(index)">
|
|
|
+ <template #reference>
|
|
|
+ <el-button :size="size" type="primary" text>删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ </avue-crud>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ </avue-crud>
|
|
|
+ </basic-container>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {getList, getDetail, add, update, remove} from "@/api/process/process";
|
|
|
+ import {getList as getListSub, getDetail as getDetailSub, add as addSub, update as updateSub, remove as removeSub} from "@/api/process/processItem";
|
|
|
+ import option from "@/option/process/process";
|
|
|
+ import optionSub from "@/option/process/processItem";
|
|
|
+ import {mapGetters} from "vuex";
|
|
|
+ import {exportBlob} from "@/api/common";
|
|
|
+ import {getToken} from '@/utils/auth';
|
|
|
+ import {downloadXls} from "@/utils/util";
|
|
|
+ import {dateNow} from "@/utils/date";
|
|
|
+ import NProgress from 'nprogress';
|
|
|
+ import 'nprogress/nprogress.css';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {},
|
|
|
+ query: {},
|
|
|
+ search: {},
|
|
|
+ loading: true,
|
|
|
+ data: [],
|
|
|
+ selectionList: [],
|
|
|
+ page: {
|
|
|
+ pageSize: 10,
|
|
|
+ currentPage: 1,
|
|
|
+ total: 0
|
|
|
+ },
|
|
|
+ option: option,
|
|
|
+ subVisible: false,
|
|
|
+ direction: 'rtl',
|
|
|
+ processId: 0,
|
|
|
+ processName: "工序表",
|
|
|
+ formSub: {},
|
|
|
+ querySub: {},
|
|
|
+ loadingSub: true,
|
|
|
+ dataSub: [],
|
|
|
+ selectionListSub: [],
|
|
|
+ pageSub: {
|
|
|
+ pageSize: 10,
|
|
|
+ currentPage: 1,
|
|
|
+ total: 0
|
|
|
+ },
|
|
|
+ optionSub: optionSub
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["permission"]),
|
|
|
+ permissionList() {
|
|
|
+ return {
|
|
|
+ addBtn: this.validData(this.permission.process_add, false),
|
|
|
+ viewBtn: this.validData(this.permission.process_view, false),
|
|
|
+ delBtn: this.validData(this.permission.process_delete, false),
|
|
|
+ editBtn: this.validData(this.permission.process_edit, false)
|
|
|
+ };
|
|
|
+ },
|
|
|
+ ids() {
|
|
|
+ let ids = [];
|
|
|
+ this.selectionList.forEach(ele => {
|
|
|
+ ids.push(ele.id);
|
|
|
+ });
|
|
|
+ return ids.join(",");
|
|
|
+ },
|
|
|
+ subIds() {
|
|
|
+ let ids = [];
|
|
|
+ this.selectionListSub.forEach(ele => {
|
|
|
+ ids.push(ele.id);
|
|
|
+ });
|
|
|
+ return ids.join(",");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 主表模块
|
|
|
+ rowSave(row, done, loading) {
|
|
|
+ if(row.isRetrospect==1){
|
|
|
+ this.$refs.detailCrud.$refs.cellForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ add(row).then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ }, error => {
|
|
|
+ window.console.log(error);
|
|
|
+ loading();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ loading();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ add(row).then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ }, error => {
|
|
|
+ window.console.log(error);
|
|
|
+ loading();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rowUpdate(row, index, done, loading) {
|
|
|
+ if(row.isRetrospect==1){
|
|
|
+ this.$refs.detailCrud.$refs.cellForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ update(row).then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ }, error => {
|
|
|
+ window.console.log(error);
|
|
|
+ loading();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ loading();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ update(row).then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ }, error => {
|
|
|
+ window.console.log(error);
|
|
|
+ loading();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rowDel(row) {
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return remove(row.id);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleDelete() {
|
|
|
+ if (this.selectionList.length === 0) {
|
|
|
+ this.$message.warning("请选择至少一条数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return remove(this.ids);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ this.$refs.crud.toggleSelection();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleExport() {
|
|
|
+ let downloadUrl = `/pl-process/process/export-process?${this.website.tokenHeader}=${getToken()}`;
|
|
|
+ const {
|
|
|
+ code,
|
|
|
+ name,
|
|
|
+ type,
|
|
|
+ isRetrospect,
|
|
|
+ } = this.query;
|
|
|
+ let values = {
|
|
|
+ code_like: code,
|
|
|
+ name_like: name,
|
|
|
+ type_: type,
|
|
|
+ isRetrospect_equal: isRetrospect,
|
|
|
+ };
|
|
|
+ this.$confirm("是否导出数据?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ NProgress.start();
|
|
|
+ exportBlob(downloadUrl, values).then(res => {
|
|
|
+ downloadXls(res.data, `工序表${dateNow()}.xlsx`);
|
|
|
+ NProgress.done();
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ beforeOpen(done, type) {
|
|
|
+ this.optionSub.menu = false;
|
|
|
+ if (["edit", "view"].includes(type)) {
|
|
|
+ getDetail(this.form.id).then(res => {
|
|
|
+ this.form = res.data.data;
|
|
|
+ if(type == "edit"){
|
|
|
+ this.optionSub.menu = true;
|
|
|
+ this.form.details.forEach(item =>{
|
|
|
+ item["$cellEdit"] = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (["add"].includes(type)) {
|
|
|
+ this.optionSub.menu = true;
|
|
|
+ if(!this.form.details){
|
|
|
+ this.form.details = [{"$cellEdit":true}]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ searchReset() {
|
|
|
+ this.query = {};
|
|
|
+ this.onLoad(this.page);
|
|
|
+ },
|
|
|
+ searchChange(params, done) {
|
|
|
+ this.query = params;
|
|
|
+ this.page.currentPage = 1
|
|
|
+ this.onLoad(this.page, params);
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ selectionChange(list) {
|
|
|
+ this.selectionList = list;
|
|
|
+ },
|
|
|
+ selectionClear() {
|
|
|
+ this.selectionList = [];
|
|
|
+ this.$refs.crud.toggleSelection();
|
|
|
+ },
|
|
|
+ currentChange(currentPage){
|
|
|
+ this.page.currentPage = currentPage;
|
|
|
+ },
|
|
|
+ sizeChange(pageSize){
|
|
|
+ this.page.pageSize = pageSize;
|
|
|
+ },
|
|
|
+ onLoad(page, params = {}) {
|
|
|
+ this.loading = true;
|
|
|
+ const {
|
|
|
+ code,
|
|
|
+ name,
|
|
|
+ type,
|
|
|
+ isRetrospect,
|
|
|
+ } = this.query;
|
|
|
+
|
|
|
+ let values = {
|
|
|
+ code_like: code,
|
|
|
+ name_like: name,
|
|
|
+ type_: type,
|
|
|
+ isRetrospect_equal: isRetrospect,
|
|
|
+ };
|
|
|
+ getList(page.currentPage, page.pageSize, values).then(res => {
|
|
|
+ const data = res.data.data;
|
|
|
+ this.page.total = data.total;
|
|
|
+ this.data = data.records;
|
|
|
+ this.loading = false;
|
|
|
+ this.selectionClear();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 子表模块
|
|
|
+ handleDataSub(row) {
|
|
|
+ this.subVisible = true;
|
|
|
+ this.processId = row.id;
|
|
|
+ this.onLoadSub(this.pageSub)
|
|
|
+ },
|
|
|
+ handleSubClose(hide) {
|
|
|
+ hide();
|
|
|
+ },
|
|
|
+ rowSaveSub(row, loading, done) {
|
|
|
+ row = {
|
|
|
+ ...row,
|
|
|
+ processId: this.processId,
|
|
|
+ };
|
|
|
+ addSub(row).then(() => {
|
|
|
+ loading();
|
|
|
+ this.onLoadSub(this.pageSub);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ }, error => {
|
|
|
+ done();
|
|
|
+ window.console.log(error);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ rowUpdateSub(row, index, loading, done) {
|
|
|
+ row = {
|
|
|
+ ...row,
|
|
|
+ processId: this.processId,
|
|
|
+ };
|
|
|
+ updateSub(row).then(() => {
|
|
|
+ loading();
|
|
|
+ this.onLoadSub(this.pageSub);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ }, error => {
|
|
|
+ done();
|
|
|
+ window.console.log(error);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ rowDelSub(row) {
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return removeSub(row.id);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoadSub(this.pageSub);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleDeleteSub() {
|
|
|
+ if (this.selectionListSub.length === 0) {
|
|
|
+ this.$message.warning("请选择至少一条数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return removeSub(this.subIds);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoadSub(this.pageSub);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ this.$refs.crudSub.toggleSelection();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ beforeOpenSub(done, type) {
|
|
|
+ if (["edit", "view"].includes(type)) {
|
|
|
+ getDetailSub(this.formSub.id).then(res => {
|
|
|
+ this.formSub = res.data.data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ searchResetSub() {
|
|
|
+ this.querySub = {};
|
|
|
+ this.onLoadSub(this.pageSub);
|
|
|
+ },
|
|
|
+ searchChangeSub(params) {
|
|
|
+ this.querySub = params;
|
|
|
+ this.onLoadSub(this.pageSub, params);
|
|
|
+ },
|
|
|
+ selectionChangeSub(list) {
|
|
|
+ this.selectionListSub = list;
|
|
|
+ },
|
|
|
+ currentChangeSub(currentPage) {
|
|
|
+ this.pageSub.currentPage = currentPage;
|
|
|
+ },
|
|
|
+ sizeChangeSub(pageSize) {
|
|
|
+ this.pageSub.pageSize = pageSize;
|
|
|
+ },
|
|
|
+ refreshChange() {
|
|
|
+ this.onLoad(this.page, this.query);
|
|
|
+ },
|
|
|
+ onLoadSub(page, params = {}) {
|
|
|
+ this.loadingSub = true;
|
|
|
+
|
|
|
+ let values = {
|
|
|
+ processId: this.processId,
|
|
|
+ }
|
|
|
+
|
|
|
+ const {
|
|
|
+ } = this.querySub;
|
|
|
+
|
|
|
+ values = {
|
|
|
+ ...values,
|
|
|
+ };
|
|
|
+
|
|
|
+ getListSub(page.currentPage, page.pageSize, values).then(res => {
|
|
|
+ const data = res.data.data;
|
|
|
+ this.pageSub.total = data.total;
|
|
|
+ this.dataSub = data.records;
|
|
|
+ this.selectionListSub = [];
|
|
|
+ this.loadingSub = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+</style>
|