| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789 |
- <template>
- <div class="ele-body">
- <el-card shadow="never">
- <seek-page
- :seekList="seekList"
- @search="search"
- ref="search"
- :keyValue="'qms-inspectionWork-index-search'"
- ></seek-page>
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :pageSize="20"
- :pageSizes="[20, 30, 40, 50, 100]"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- row-key="id"
- @selection-change="selectionChangeHandle"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- v-if="$hasPermission('qms:quality_work_order:close')"
- size="small"
- type="primary"
- class="ele-btn-icon"
- @click="batchClose"
- :disabled="selection.length === 0"
- >
- 批量关闭
- </el-button>
- </template>
- <template v-slot:code="{ row }">
- <el-link
- type="primary"
- :underline="false"
- @click="openDetails(row)"
- >{{ row.code }}</el-link
- >
- </template>
- <template v-slot:sourceCode="{ row }">
- <div>{{
- row.qualityPlanCode ? row.qualityPlanCode : row.workOrderCode
- }}</div>
- </template>
- <template v-slot:files="scope">
- <el-link
- v-for="link in scope.row.files"
- :key="link.id"
- type="primary"
- :underline="false"
- @click="downloadFile(link)"
- >{{ link.name }}</el-link
- >
- </template>
- <template v-slot:qualityType="{ row }">{{
- getDictValue('质检计划类型', row.qualityType)
- }}</template>
- <template v-slot:qualityMode="{ row }">{{
- getDictValue('取样类型', row.qualityMode)
- }}</template>
- <template v-slot:accessory="scope">
- <el-link
- v-for="link in scope.row.accessory"
- :key="link.id"
- type="primary"
- :underline="false"
- @click="downloadFile(link)"
- >{{ link.name }}</el-link
- >
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <!-- <el-link
- type="primary"
- :underline="false"
- @click="addSampleOpen(row)"
- >取样</el-link
- > -->
- <el-link
- type="primary"
- :underline="false"
- v-if="row.status == 0 && $hasPermission('qms:quality_work_order:update')"
- @click="openEdit('edit', row)"
- >报工</el-link
- >
- <el-link
- type="primary"
- :underline="false"
- v-if="row.status == 0 && $hasPermission('qms:quality_work_order:transfer')"
- @click="openTransfer(row.id)"
- >转派</el-link
- >
- <el-link v-if="$hasPermission('qms:quality_work_order:certificate')" type="primary" :underline="false" @click="openNumber(row)"
- >合格证</el-link
- >
- <jimureportBrowse
- style="display: inline-block; margin-left: 5px"
- v-if="row.status == 1 && $hasPermission('qms:quality_work_order:qualityReport')"
- text="质检报告"
- :businessId="row.id"
- businessCode="qmsqualityinspectionprint"
- ></jimureportBrowse>
- <el-dropdown
- trigger="click"
- v-if="
- row.status == 1 &&
- isReportApproval == 1 &&
- (!row.reportApprovalStatus || row.reportApprovalStatus == 0) && isEmptyObject(row.reportTemplateJson) &&
- $hasPermission('qms:quality_work_order:generateReport')
- "
- >
- <el-link
- type="primary"
- :underline="false"
- >生成质检报告</el-link
- >
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- v-for="item in reportTemplateList"
- :key="item.id"
- @click.native="generateReportApproval(row, item)"
- >{{ item.name }}</el-dropdown-item
- >
- </el-dropdown-menu>
- </el-dropdown>
- <el-link
- v-if="
- row.status == 1 &&
- isReportApproval == 1 &&
- (row.reportApprovalStatus && !isEmptyObject(row.reportTemplateJson)) &&
- $hasPermission('qms:quality_work_order:generateReport')
- "
- type="primary"
- :underline="false"
- @click="openReport(row)"
- >查看质检报告</el-link
- >
- <!-- 质检报告审批 -->
- <el-link
- v-if="
- row.status == 1 &&
- isReportApproval == 1 &&
- !row.reportApprovalStatus &&
- $hasPermission('qms:quality_work_order:qualityReportApproval')
- "
- type="primary"
- :underline="false"
- @click="reportApprovalSubmit(row)"
- >质检报告审批</el-link
- >
- <el-popconfirm
- class="ele-action"
- title="确定要关闭吗?"
- @confirm="close(row)"
- v-if="row.status == 0 && row.qualityType == 2 && $hasPermission('qms:quality_work_order:close')"
- >
- <template v-slot:reference>
- <el-link type="warning" :underline="false"> 关闭 </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </el-card>
- <Certificate
- @search="search"
- v-if="addOpen"
- :rowData="rowData"
- :addOpen="addOpen"
- @closeModel="closeModel"
- />
- <Transfer
- v-if="transferVisible"
- :transferVisible.sync="transferVisible"
- @success="transferConfirm"
- :id="transferId"
- ></Transfer>
- <process-submit-dialog
- api-fun-name="qmsReportApprovalAPI"
- :processSubmitDialogFlag.sync="processSubmitDialogFlag"
- :isCloseRefresh="false"
- v-if="processSubmitDialogFlag"
- ref="processSubmitDialogRef"
- @reload="search"
- ></process-submit-dialog>
- <addSample ref="addSampleRef" @reload="search"></addSample>
- <!-- <inspectionReport1 ref="qualityRef" @reload="search" :isView="true"></inspectionReport1> -->
- <component
- :is="targetComponent"
- ref="targetComponentRef"
- v-if="targetComponent"
- :key="targetComponent"
- :isView="isView"
- :visible.sync="targetVisible"
- :row="currentRow"
- :item="currentItem"
- @reload="search"
- ></component>
- </div>
- </template>
- <script>
- import Certificate from './components/Certificate.vue';
- import search from './components/search.vue';
- import addSample from './components/addSample.vue';
- import jimureportBrowse from '@/components/jimureport/browseModal.vue';
- import Transfer from './components/transfer.vue';
- import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
- import {
- getList,
- removeItem,
- updateCertificateNumber,
- closeWorkList,
- verificationQualityInspector,
- closeWork
- } from '@/api/inspectionWork';
- import { queryTodo } from '@/api/bpm/task';
- import dictMixins from '@/mixins/dictMixins';
- import { getFile } from '@/api/system/file';
- import { getByCode } from '@/api/system/dictionary-data';
- import { parameterGetByCode } from '@/api/main/index';
- import tabMixins from '@/mixins/tableColumnsMixin';
- import { getCategoryByCode } from '@/api/main/index';
- import { getQmsReportTemplatePageList } from '@/api/inspectionWork';
- import inspection_report1 from '../inspectionReport/template/inspection_report1.vue';
- export default {
- mixins: [dictMixins, tabMixins],
- components: {
- search,
- jimureportBrowse,
- Certificate,
- Transfer,
- processSubmitDialog,
- addSample,
- inspection_report1
- },
- data() {
- return {
- cacheKeyUrl: 'qsm-c2e9664a-inspectionWork',
- targetComponent: null,
- isView: false,
- targetVisible: false,
- currentRow: {},
- currentItem: {},
- columns: [
- // 新增多选列
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- reserveSelection: true
- },
- {
- type: 'index',
- columnKey: 'index',
- align: 'center',
- label: '序号',
- width: 55,
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'code',
- label: '质检工单编码',
- slot: 'code',
- align: 'center',
- width: 180,
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'name',
- slot: 'name',
- width: 120,
- label: '质检工单名称',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '来源单号',
- prop: 'sourceCode',
- slot: 'sourceCode',
- align: 'center',
- width: 160,
- showOverflowTooltip: true
- },
- {
- label: '类型',
- prop: 'qualityType',
- slot: 'qualityType',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '质检方式',
- prop: 'qualityMode',
- slot: 'qualityMode',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'qualityName',
- label: '质检人',
- align: 'center',
- width: 120,
- showOverflowTooltip: true,
- formatter: (row) => {
- if (row.qualityName) {
- return row.qualityName;
- }
- return row.qualityNames || '';
- }
- },
- {
- prop: 'qualityTime',
- label: '质检时间',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'productCode',
- width: 120,
- label: '编码',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'productName',
- width: 120,
- label: '名称',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'batchNo',
- label: '批次号',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'brandNo',
- label: '牌号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'produceTaskName',
- label: '工序',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- prop: 'total',
- label: '总数量',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'qualifiedNumber',
- label: '合格数',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'qualificationRate',
- label: '合格率',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'noQualifiedNumber',
- label: '不合格数',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'noQualificationRate',
- label: '不合格率',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'hours',
- label: '工时',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '附件',
- prop: 'accessory',
- align: 'center',
- slot: 'accessory',
- showOverflowTooltip: true
- },
- {
- label: '创建时间',
- prop: 'createTime',
- align: 'center',
- width: 160
- },
- {
- prop: 'status',
- label: '状态',
- align: 'center',
- width: 80,
- formatter: (row, column, cellValue) => {
- // 状态(0未报工;1已报工;2已关闭;3待取样)
- switch (cellValue) {
- case 0:
- return '未报工';
- case 1:
- return '已报工';
- case 2:
- return '已关闭';
- case 3:
- return '待取样';
- default:
- return '';
- }
- },
- fixed: 'right'
- },
- {
- columnKey: 'action',
- label: '操作',
- align: 'center',
- width: 200,
- resizable: false,
- slot: 'action',
- fixed: 'right'
- }
- ],
- formData: {
- certificateNumber: ''
- },
- processSubmitDialogFlag: false,
- rowData: {},
- typeList: [], //类型列表
- qualityMode: [], //取样类型
- // 状态(0未报工;1已报工;2已关闭;3待取样)
- statusList: [
- {
- value: 0,
- label: '未报工'
- },
- {
- value: 1,
- label: '已报工'
- }
- // ,
- // {
- // value: 2,
- // label: '已关闭'
- // },
- // {
- // value: 3,
- // label: '待取样'
- // }
- ],
- addOpen: false,
- transferVisible: false,
- transferId: '',
- isReportApproval: 0,
- selection: [], // 存储选中的行数据
- reportTemplateList: [], // 报表模板列表
- templateArr: ['inspection_report1', 'ABBCCC']
- };
- },
- created() {
- this.requestDict('质检计划类型');
- this.requestDict('不良品处理类型');
- this.requestDict('取样类型');
- this.getCode();
- this.getReportTemplateList();
- this.getTnspectionPlanType();
- this.getQualityMethodCode();
- },
- computed: {
- seekList() {
- return [
- {
- label: '工单编码:',
- value: 'code',
- type: 'input',
- placeholder: ''
- },
- {
- label: '工单名称:',
- value: 'name',
- type: 'input',
- placeholder: ''
- },
- {
- label: '来源单号:',
- value: 'sourceCode',
- type: 'input',
- placeholder: ''
- },
- {
- label: '类型:',
- value: 'qualityType',
- type: 'select',
- placeholder: '',
- planList: this.typeList
- },
- {
- label: '质检方式:',
- value: 'qualityMode',
- type: 'select',
- placeholder: '',
- planList: this.qualityMode
- },
- {
- label: '编码:',
- value: 'productCode',
- type: 'input',
- placeholder: ''
- },
- {
- label: '名称:',
- value: 'productName',
- type: 'input',
- placeholder: ''
- },
- {
- label: '质检人:',
- value: 'qualityName',
- type: 'input',
- placeholder: ''
- },
- {
- label: '状态:',
- value: 'status',
- type: 'select',
- placeholder: '',
- planList: this.statusList
- }
- ];
- },
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- }
- },
- methods: {
- getReportTemplateList() {
- getQmsReportTemplatePageList({
- pageNum: 1,
- pageSize: 999,
- isEnabled: 1
- }).then((res) => {
- this.reportTemplateList = res.list;
- console.log('reportTemplateList', this.reportTemplateList);
- }).catch((err) => {
- console.error('获取报表模板列表失败:', err);
- // this.$message.error('获取报表模板列表失败:' + (err.message || '操作异常'));
- });
- },
- generateReportApproval(row, item) {
- console.log('item~~~', item);
- console.log('generateReportApproval', row, item);
- this.targetComponent = item.code;
- this.isView = false;
- this.currentRow = row;
- this.currentItem = item;
- // this.$refs.targetComponentRef.open(item, row);
- this.$nextTick(() => {
- // this.$refs.targetComponentRef.open(row, isView);
- this.targetVisible = true;
- console.log('targetVisible~~~~', this.targetVisible);
- });
- },
- openReport(row) {
- console.log('openReport', row);
- this.targetComponent = row.reportTemplateCode;
- this.isView = true;
- this.currentRow = row;
- this.$nextTick(() => {
- this.targetVisible = true;
- });
- },
- selectionChangeHandle(val) {
- this.selection = val;
- },
- addSampleOpen(row) {
- this.$refs.addSampleRef.open(row);
- },
- // 批量关闭
- batchClose() {
- const validRows = this.selection.filter(
- (row) => row.status === 0 && row.qualityType === 2
- );
- if (validRows.length === 0) {
- this.$message.warning('所选工单中没有可关闭的工单');
- return;
- }
- this.$confirm(`确定关闭选中的 ${validRows.length} 个工单吗?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(async () => {
- try {
- await closeWorkList(validRows.map((row) => row.id));
- this.$refs.table.clearSelection();
- this.search();
- } catch (err) {
- this.$message.error('批量关闭失败:' + (err.message || '操作异常'));
- }
- });
- },
- reportApprovalSubmit(res) {
- this.processSubmitDialogFlag = true;
- this.$nextTick(async () => {
- let params = {
- businessId: res.id,
- businessKey: 'qms_report_approval',
- formCreateUserId: res.createUserId,
- variables: {
- businessCode: res.code,
- businessName: res.name,
- businessType: '质检报告单'
- }
- };
- if (this.clientEnvironmentId == 5) {
- const data = await getCategoryByCode(res.productCode);
- if (data && data.categoryLevelCodePath?.includes('W3-209')) {
- params.businessKey = 'qms_report_approval1';
- } else {
- params.businessKey = 'qms_report_approval';
- }
- }
- this.$refs.processSubmitDialogRef.init(params);
- });
- },
- getCode() {
- parameterGetByCode({
- code: 'qms_report_approval'
- }).then((res) => {
- this.isReportApproval = res.value;
- });
- },
- async datasource({ page, where, limit }) {
- try {
- await queryTodo({});
- } catch (err) {
- console.error('调用queryTodo失败:', err);
- }
- return getList({
- ...where,
- pageNum: page,
- size: limit
- });
- },
- search(where) {
- this.$refs.table.reload({
- where: where
- // page: 1
- });
- },
- isEmptyObject(obj) {
- return Object.keys(obj).length === 0;
- },
- async openEdit(type, row) {
- const menusList = this.$store.state.user.menus;
- let found = false;
- if (type == 'edit') {
- const code = await verificationQualityInspector(row.id);
- if (code == '-1') {
- return;
- }
- }
- for (const item of menusList) {
- if (item.children) {
- for (const item2 of item.children) {
- if (item2.path === '/inspectionWork/edit') {
- found = true;
- const id = type !== 'add' ? row.id : '';
- const qualityType = type !== 'add' ? row.qualityType : null;
- const qualityTimeStart = row.qualityTimeStart || '';
- this.$router.push({
- path: '/inspectionWork/edit',
- query: {
- type,
- id,
- qualityType,
- qualityTimeStart
- }
- });
- return;
- }
- }
- }
- }
- if (!found) {
- this.$message.error('请到角色管理配置菜单权限!');
- }
- },
- openDetails(row) {
- let id = row.id;
- this.$router.push({
- path: '/inspectionWork/details',
- query: { id, path: '/inspectionWork', name: '工单' }
- });
- },
- downloadFile(file) {
- getFile({ objectName: file.storePath }, file.name);
- },
- remove(row) {
- removeItem([row.id])
- .then((message) => {
- this.$message.success(message);
- this.done();
- })
- .catch((e) => {});
- },
- done() {
- this.$refs.search.search();
- },
- openNumber(row) {
- this.formData.certificateNumber = row.certificateNumber;
- this.rowData = row;
- this.addOpen = true;
- },
- closeModel() {
- this.addOpen = false;
- },
- async close(row) {
- await closeWork(row);
- this.done();
- },
- async getTnspectionPlanType() {
- let res = await getByCode('inspection_plan_type');
- if (res?.code == 0) {
- let list = res.data.map((item) => {
- let key = Object.keys(item)[0];
- return { value: key, label: item[key] };
- });
- this.typeList = list;
- }
- },
- async getQualityMethodCode() {
- let res = await getByCode('quality_method_code');
- if (res?.code == 0) {
- let list = res.data.map((item) => {
- let key = Object.keys(item)[0];
- return { value: key, label: item[key] };
- });
- this.qualityMode = list;
- }
- },
- openTransfer(id) {
- this.transferVisible = true;
- this.transferId = id;
- },
- transferConfirm(id) {
- this.transferVisible = false;
- this.$message.success('转派成功');
- this.done();
- }
- }
- };
- </script>
|