| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- <template>
- <el-dialog
- :visible.sync="dialogVisible"
- :title="dialogTile"
- :before-close="handleClose"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- v-loading="addDialogLoading"
- width="80%"
- >
- <HeaderTitle title="基本信息" size="16px"></HeaderTitle>
- <el-form
- :model="addForm"
- class="add_form"
- ref="addFormRef"
- :rules="rules"
- label-width="110px"
- >
- <el-row :gutter="20">
- <el-col :span="8">
- <el-form-item label="计划配置单号" prop="code">
- <el-input
- v-model="addForm.code"
- placeholder="自动生成"
- disabled
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="计划配置名字" prop="name">
- <el-input
- :disabled="isBindPlan"
- v-model="addForm.name"
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="自动派单" prop="autoOrder">
- <el-select
- v-model="addForm.autoOrder"
- class="w100"
- placeholder="请选择"
- :disabled="isBindPlan"
- filterable
- >
- <el-option :value="1" label="是"></el-option>
- <el-option :value="0" label="否"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="规则名称" prop="ruleId">
- <el-select
- v-model="addForm.ruleId"
- class="w100"
- placeholder="请选择规则名称"
- @change="change_ruleId"
- :disabled="isBindPlan"
- filterable
- >
- <el-option
- v-for="item in ruleNameList"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- @click.native="addForm.ruleName = item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="计划盘点时长" prop="executorDuration">
- <el-input
- v-model.number="addForm.executorDuration"
- placeholder="请输入"
- :disabled="isBindPlan"
- >
- <template #suffix>分钟</template>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="盘点仓库" prop="warehouseId">
- <el-select
- placeholder="请选择"
- class="w100"
- :disabled="isBindPlan"
- v-model="addForm.warehouseId"
- @change="changeWarehouse"
- filterable
- >
- <el-option
- v-for="item in warehouseList"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- @click.native="
- () => {
- addForm.bizTypeName = item.name;
- }
- "
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="审核人" prop="approvalUserId">
- <el-select
- v-model="addForm.approvalUserId"
- size="small"
- style="width: 100%"
- :disabled="isBindPlan"
- filterable
- >
- <el-option
- v-for="item in uerList"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="紧急程度" prop="urgent">
- <DictSelection
- :isProhibit="isBindPlan"
- dictName="紧急程度"
- clearable
- filterable
- v-model="addForm.urgent"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8" v-if="addForm.autoOrder">
- <el-form-item label="执行部门" prop="executeGroupId">
- <deptSelect
- :isBindPlan="isBindPlan"
- v-model="addForm.executeGroupId"
- @changeGroup="searchDeptNodeClick"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8" v-if="addForm.autoOrder">
- <el-form-item label="执行人员" prop="executorId">
- <el-select
- v-model="addForm.executorId"
- @change="changeExecutor"
- :disabled="isBindPlan"
- size="small"
- style="width: 100%"
- filterable
- >
- <el-option
- v-for="item in executorList"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <!-- <el-col :span="8">
- <el-form-item label="锁库盘点" prop="isTreasuryLock">
- <el-switch
- v-model="addForm.lockWarehouse"
- active-text="开"
- inactive-text="关"
- :active-value="1"
- :inactive-value="0"
- :disabled="isBindPlan"
- ></el-switch>
- </el-form-item>
- </el-col> -->
- <el-col :span="24">
- <el-form-item label="备注" prop="remark">
- <el-input
- placeholder="请输入"
- type="textarea"
- :rows="2"
- resize="none"
- v-model="addForm.remark"
- :disabled="isBindPlan"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <HeaderTitle title="盘点物品信息" size="16px">
- <el-select
- :disabled="isBindPlan"
- @change="dimensionChange"
- v-model="dimension"
- placeholder="请选择维度"
- >
- <el-option label="物品维度" :value="1"> </el-option>
- <el-option label="批次维度" :value="2"> </el-option>
- </el-select>
- <el-button
- v-if="!isBindPlan"
- style="margin-left: 10px"
- type="primary"
- @click="addProducts"
- >添加物品</el-button
- >
- </HeaderTitle>
- <el-table
- ref="table"
- :data="productList"
- :height="500"
- row-key="id"
- tooltip-effect="dark"
- border
- >
- <el-table-column label="序号" type="index" width="50">
- </el-table-column>
- <el-table-column
- label="物品编码"
- prop="categoryCode"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="物品名称"
- prop="categoryName"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- width="150"
- prop="categoryLevelPath"
- label="产品分类"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="批次号"
- prop="batchNo"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="牌号"
- prop="brandNum"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="型号"
- prop="categoryModel"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="规格"
- prop="specification"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="计量数量"
- prop="measureQuantity"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="计量单位"
- prop="measureUnit"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="重量"
- prop="weight"
- :show-overflow-tooltip="true"
- >
- </el-table-column>
- <el-table-column
- label="重量单位"
- prop="weightUnit"
- :show-overflow-tooltip="true"
- >
- </el-table-column>
- <el-table-column v-if="!isBindPlan" label="操作" width="100">
- <template slot-scope="{ row, $index }">
- <el-button @click="deleted(row, $index)" type="text" size="small"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- <div v-if="!isBindPlan" slot="footer">
- <el-button type="primary" size="small" @click="submit">提交</el-button>
- <el-button size="small" @click="handleClose">关闭</el-button>
- </div>
- <div v-else slot="footer">
- <el-button type="primary" size="small" @click="dialogVisible = false"
- >确定</el-button
- >
- <el-button size="small" @click="dialogVisible = false">关闭</el-button>
- </div>
- <selectType
- :visibleDialog.sync="visibleDialog"
- :treeIds="productType"
- :dimension="dimension"
- :warehouseId="addForm.warehouseId"
- :selectionIds="selectionIds"
- :loadTree.sync="loadTree"
- @selectTableData="addGoods"
- />
- </el-dialog>
- </template>
- <script>
- import { getTreeByGroup } from '@/api/classifyManage';
- import selectType from './selectType.vue';
- import { getCode } from '@/api/codeManagement';
- import {
- getInventoryPlanDetailById,
- saveInventoryPlan,
- updateInventoryPlan
- } from '@/api/inventory';
- import {
- getRule,
- getWarehouseList,
- getCategoryLevelIdByWarehouseId
- } from '@/api/ruleManagement/plan';
- import { getUserPage } from '@/api/system/organization';
- import deptSelect from '@/components/CommomSelect/new-dept-select.vue';
- export default {
- props: {
- dialogTile: {
- type: String,
- default: '新增临时盘点计划'
- },
- isBindPlan: {
- type: Boolean,
- default: function () {
- return false;
- }
- },
- id: {
- type: String,
- default: ''
- }
- },
- components: {
- deptSelect,
- selectType
- },
- data() {
- return {
- visibleDialog: false,
- type: 2, // 盘点类型 2仓储 4资产
- dimension: 1, // 盘点维度1物品 2批次
- factoryOptions: [],
- workshopOptions: [],
- productionLineOptions: [],
- stationOptions: [],
- codeList: [],
- addDialogLoading: false,
- dialogVisible: false,
- wh_checkStatus: [], // 盘点类型
- warehouseList: [], // 盘点仓库
- uerList: [], // 审核人
- executorList: [], // 执行人
- assetsType: null,
- planRuleInventoryDetailList: [],
- tableList: [],
- newColumns: [],
- selection: [],
- keyWord: '',
- total: 0,
- page: 1,
- size: 10,
- loadTree: true,
- productList: [],
- productType: [],
- addForm: {
- ruleId: '', // 规则名称
- ruleName: '', // 规则名称
- code: '', // 计划配置单号
- name: '', // 计划配置名称
- executeGroupId: '', // 执行部门code
- executeGroupName: '', // 执行部门name
- executorId: '', // 执行人id
- executorName: '', // 执行人name
- lockWarehouse: 1, // 是否锁库盘点
- urgent: '1', // 紧急程度
- warehouseId: '', // 盘点仓库Id
- autoOrder: 1, // 是否自动派单
- remark: '', // 备注
- approvalUserId: '', // 审核人Id
- approvalUserName: '', // 审核人name
- executorDuration: 0 // 盘点时长
- },
- rules: {
- code: [
- { required: true, message: '请输入计划配置单号', trigger: 'blur' }
- ],
- name: [
- { required: true, message: '请输入计划配置名称', trigger: 'blur' }
- ],
- autoOrder: [
- { required: true, message: '请选择是否自动派单', trigger: 'change' }
- ],
- ruleId: [
- { required: true, message: '请选择规则名称', trigger: 'change' }
- ],
- executorDuration: [
- { required: true, message: '请输入计划完成时长', trigger: 'blur' }
- ],
- warehouseId: [
- { required: true, message: '请选择盘点仓库', trigger: 'change' }
- ],
- executeGroupId: [
- { required: true, message: '请选择选择执行部门', trigger: 'change' }
- ],
- executorId: [
- { required: true, message: '请选择选择执行人员', trigger: 'change' }
- ]
- },
- ruleNameList: []
- };
- },
- watch: {
- dialogVisible(val) {
- if (val) {
- // 获取审核人列表数据
- this.getUserList();
- // 获取盘点仓库
- this._getWarehouse();
- // 获取计划单号
- this.getOrderCode();
- // 获取规则名称
- this._getRuleNameList();
- // 获取物品类型
- this.getGoodsList();
- if (
- this.dialogTile === '修改临时盘点计划' ||
- this.dialogTile === '临时盘点计划详情'
- ) {
- getInventoryPlanDetailById(this.id).then(async (res) => {
- res.urgent = String(res.urgent);
- this.addForm = res;
- this.dimension = res.planDetailVOS[0].batchNo ? 2 : 1;
- if (this.addForm.executeGroupId) {
- this.getUserList({ groupId: this.addForm.executeGroupId });
- }
- this.productList = res.planDetailVOS.map((item) => item.info);
- getCategoryLevelIdByWarehouseId({
- warehouseId: this.addForm.warehouseId
- }).then((data) => {
- console.log(data);
- this.productType = Array.from(new Set(data));
- });
- });
- } else {
- this.productList = [];
- this.addForm = {
- ruleId: '', // 规则名称
- ruleName: '', // 规则名称
- code: '', // 计划配置单号
- executeGroupId: '', // 执行部门code
- executeGroupName: '', // 执行部门name
- executorId: '', // 执行人id
- executorName: '', // 执行人name
- lockWarehouse: 1, // 是否锁库盘点
- urgent: '1', // 紧急程度
- warehouseId: '', // 盘点仓库Id
- autoOrder: 1, // 是否自动派单
- remark: '', // 备注
- approvalUserId: '', // 审核人Id
- approvalUserName: '', // 审核人name
- executorDuration: 0 // 盘点时长
- };
- }
- }
- }
- },
- computed: {
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- selectionIds() {
- return this.productList.map((item) => item.categoryId);
- }
- },
- methods: {
- // 添加物品明细
- async addGoods(data) {
- console.log(data);
- let productList = data.map((item) => {
- return {
- ...item
- };
- });
- this.productList = this.productList.concat(productList);
- },
- addProducts() {
- if (this.addForm.warehouseId) {
- console.log(this.addForm.warehouseId);
- this.visibleDialog = true;
- } else {
- this.$message.warning('请选择盘点仓库');
- }
- },
- deleted(row, index) {
- this.productList.splice(index, 1);
- },
- selecctedRow(val) {
- this.selection = val;
- },
- dimensionChange() {
- this.productList = [];
- },
- checkSelectable(row) {
- return true;
- },
- // 改变规则名称
- change_ruleId(val) {
- this.addForm.ruleName = this.ruleNameList.filter(
- (item) => item.id === val
- )[0].name;
- },
- // 获取物品类型列表
- async getGoodsList() {
- const { data } = await getTreeByGroup({ type: this.type });
- console.log('data------', data);
- this.codeList = data;
- },
- // 获取规则名列表
- async _getRuleNameList() {
- const res = await getRule({ status: 1, type: 4, pageNum: 1, size: -1 });
- if (res.list) {
- this.ruleNameList = res.list || [];
- }
- },
- // 获取计划配置单号
- async getOrderCode(tips) {
- const code = await getCode('inventoryconfig_code');
- this.$set(this.addForm, 'code', code);
- },
- // 执行人选择
- changeExecutor(val) {
- if (val) {
- this.addForm.executorId = val;
- this.addForm.executorName = this.executorList.filter(
- (item) => item.id === val
- )[0].name;
- }
- },
- // 仓库选择
- changeWarehouse(val) {
- if (val) {
- this.addForm.warehouseId = val;
- this.addForm.warehouseName = this.warehouseList.filter(
- (item) => item.id === val
- )[0].name;
- this.productList = [];
- getCategoryLevelIdByWarehouseId({ warehouseId: val }).then((data) => {
- console.log(data);
- this.productType = Array.from(new Set(data));
- });
- }
- },
- // 关闭弹窗
- handleClose() {
- this.dialogVisible = false;
- this.$refs.addFormRef.resetFields();
- this.addForm.assetsName = '';
- this.assetsType = null;
- this.addForm = {
- ruleId: '', // 规则名称
- ruleName: '', // 规则名称
- code: '', // 计划配置单号
- executeGroupId: '', // 执行部门code
- executeGroupName: '', // 执行部门name
- executorId: '', // 执行人id
- executorName: '', // 执行人name
- lockWarehouse: 1, // 是否锁库盘点
- urgent: '1', // 紧急程度
- warehouseId: '', // 盘点仓库Id
- autoOrder: 1, // 是否自动派单
- remark: '', // 备注
- approvalUserId: '', // 审核人Id
- approvalUserName: '', // 审核人name
- executorDuration: 0 // 盘点时长
- };
- },
- // 封装 - 获取盘点仓库
- async _getWarehouse() {
- const res = await getWarehouseList({});
- this.warehouseList = res.map((item) => {
- return { ...item, name: item.factoryName + '-' + item.name };
- });
- },
- //选择部门(搜索)
- searchDeptNodeClick(info, row) {
- console.log(info);
- console.log(row);
- if (info) {
- const params = { groupId: info };
- this.getUserList(params);
- this.addForm.executeGroupName = row.name;
- } else {
- this.addForm.executeGroupId = null;
- }
- },
- // 获取审核人列表、巡点检人员
- async getUserList(params) {
- try {
- let data = { pageNum: 1, size: -1 };
- // 如果传了参数就是获取巡点检人员数据
- if (params) {
- data = Object.assign(data, params);
- }
- const res = await getUserPage(data);
- if (params) {
- this.executorList = res.list;
- } else {
- this.uerList = res.list;
- }
- } catch (error) {}
- },
- submit() {
- console.log(this.addForm);
- this.$refs.addFormRef.validate(async (valid) => {
- let res = null;
- if (valid) {
- let params = {
- ...this.addForm,
- planDetailAddPOList: this.productList.map((item) => {
- return {
- batchNo: item.batchNo,
- categoryId: item.categoryId,
- categoryName: item.categoryName,
- info: item
- };
- })
- };
- if (this.productList?.length > 0) {
- if (this.dialogTile === '修改临时盘点计划') {
- res = await updateInventoryPlan(params);
- } else {
- res = await saveInventoryPlan(params);
- }
- } else {
- return this.$message.error('请选择需要盘点物品');
- }
- if (res.code == 0) {
- this.handleClose();
- console.log(res.message);
- this.$message.success({
- message:res.message,
- duration:2000
- });
- this.$emit('refreshList');
- }
- }
- });
- },
- handleChangeassetDict(data) {
- console.log(data);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep .el-row {
- display: flex;
- flex-wrap: wrap;
- }
- .add_form {
- ::v-deep .el-form-item {
- margin-bottom: 20px !important;
- }
- }
- .table_search {
- margin-bottom: 5px;
- }
- </style>
|