123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <template>
- <div
- class="mainContentBox"
- style="padding: 0; box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1)"
- >
- <div class="header">
- <div class="title">绑定工序</div>
- <el-space>
- <el-button :icon="Back" size="small" @click="back">返回</el-button>
- <el-button
- :type="isChanged ? 'danger' : 'primary'"
- :icon="Document"
- size="small"
- @click="save"
- >保存</el-button
- >
- </el-space>
- </div>
- <div class="types">
- <el-dropdown @command="handleCommand">
- <div class="typeBox addBtn">
- <el-icon class="icon"><CirclePlus /></el-icon>
- <div class="name">添加组件</div>
- </div>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- v-for="(com, index) in comTypes"
- :key="index"
- :command="com"
- >
- <div
- v-if="
- prodtCode != '' ||
- (prodtCode == '' && com.compentName != '物料采集')
- "
- >
- {{ com.compentName }}
- </div></el-dropdown-item
- >
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- <VueDraggable
- v-model="selectProComs"
- :animation="150"
- ghostClass="ghost"
- @update="onUpdate"
- style="display: flex"
- >
- <div
- class="typeContainer"
- v-for="(item, index) in selectProComs"
- :key="index"
- @click="clickToolCom(item, index)"
- >
- <div class="typeBox others" :class="getNameClass(index)">
- <svg-icon :icon-class="item.compentType" size="30" />
- <div class="name">{{ item.compentName }}</div>
- </div>
- <Delete class="delete" @click.stop="clickDelete(index)" />
- </div>
- </VueDraggable>
- </div>
- <div class="binContainer">
- <div v-if="isChanged || selectIndex === -1 || isNoneedEdit">
- <el-empty :image-size="200" :description="getTipContent()" />
- </div>
- <div v-else-if="tipTitle !== '编辑工序表格'">
- <div class="tipTitle">{{ tipTitle }}</div>
- <el-button
- type="primary"
- @click="creatNewData"
- style="margin-bottom: 15px"
- >新增</el-button
- >
- <el-button
- type="primary"
- @click="saveSortData"
- style="margin-bottom: 15px"
- >保存顺序</el-button
- >
- <BottomTable ref="bottomTableRef" :tableType="tableType" />
- </div>
- <div v-else>
- <div class="tipTitle">{{ tipTitle }}</div>
- <SetExcel />
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { Back, Document, CirclePlus, Delete } from "@element-plus/icons-vue";
- import { VueDraggable } from "vue-draggable-plus";
- import BottomTable from "@/views/base/craftManagement/route/components/bottomTable.vue";
- import SetExcel from "./setExcel/index.vue";
- import { comTypes } from "@/views/base/craftManagement/route/components/configs";
- import { saveCompoents, getCompoentsList } from "@/api/craft/process/index";
- import { useCommonStoreHook, useDictionaryStoreHook } from "@/store";
- import {
- processesByRouteId,
- saveProcessInRoute,
- } from "@/api/craft/route/index";
- const prodtCode = ref("");
- const routerId = ref("");
- const router = useRouter();
- const route = useRoute();
- //组件是否已经改变,如果改变了需要点击保存,才能展示下面的table
- const isChanged = ref(true);
- const isNoneedEdit = ref(false); //有些组件是不需要编辑的,所以下面也不展示table
- const loadTopList = () => {
- getCompoentsList(routerId.value).then((res) => {
- selectProComs.value = res.data || [];
- selectIndex.value = -1;
- isChanged.value = false;
- });
- };
- onMounted(async () => {
- prodtCode.value = route.fullPath.split("/")[5];
- routerId.value = route.fullPath.split("/")[6];
- await loadTopList();
- });
- // 顶部====================
- const back = () => {
- router.back();
- };
- const save = async () => {
- for (let i = 0; i < selectProComs.value.length; i++) {
- selectProComs.value[i].operationId = routerId.value;
- selectProComs.value[i].sortNum = i;
- }
- let p = {
- operationId: routerId.value,
- dtos: selectProComs.value,
- };
- let { res, code } = await saveCompoents(p);
- if (code == "200") {
- ElMessage.success("保存成功");
- }
- loadTopList();
- };
- // Tools顶部组件 ==================
- // 已经存在的工序组件
- const selectProComs = ref([]);
- const selectIndex = ref(-1);
- const currentCom = ref({});
- const handleCommand = (item) => {
- let status = true;
- for (let i = 0; i < selectProComs.value.length; i++) {
- if (selectProComs.value[i].compentName == item.compentName) {
- status = false;
- }
- }
- if (status == true) {
- selectProComs.value.push(item);
- isChanged.value = true;
- selectIndex.value = -1;
- } else {
- ElMessage.error("请勿重复添加");
- }
- };
- // 点击某一个改变下面的table
- const clickToolCom = (com, index) => {
- // 如果上方组件更改了,提示先保存组件再操作
- if (isChanged.value) {
- ElMessage.warning("请先保存组件!!!");
- return;
- }
- tipTitle.value = "编辑" + com.compentName;
- selectIndex.value = index;
- currentCom.value = com;
- if (
- com.compentType === "jiluxiang" ||
- com.compentType === "mingpai" ||
- com.compentType === "duomeiticaiji" ||
- com.compentType === "tiaoshipipei" ||
- com.compentType === "jingu"
- ) {
- isNoneedEdit.value = true;
- } else {
- tableType.value = com.compentType;
- isNoneedEdit.value = false;
- }
- };
- const onUpdate = () => {
- isChanged.value = true;
- selectIndex.value = -1;
- };
- const clickDelete = (index) => {
- selectProComs.value.splice(index, 1);
- selectIndex.value = -1;
- isChanged.value = true;
- };
- const getNameClass = (index) => {
- return index === selectIndex.value ? "selected" : "normal";
- };
- // 底部table ===============
- let tipTitle = ref({});
- const bottomTableRef = ref({});
- const tableType = ref("MARTERIAL_BOM");
- const creatNewData = () => {
- bottomTableRef.value && bottomTableRef.value.startCreat();
- };
- const saveSortData = () => {
- bottomTableRef.value && bottomTableRef.value.saveSortData();
- };
- const getTipContent = (itemValue) => {
- if (isNoneedEdit.value) {
- return "标准组件无需编辑";
- }
- if (selectIndex.value === -1 && isChanged.value) {
- return "请先保存组件,然后再进行操作";
- }
- return "请先选择组件";
- };
- </script>
- <style lang="scss" scoped>
- .header {
- height: 50px;
- display: flex;
- background-color: #f5f7f9;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
- }
- .types {
- width: 100%;
- height: 116px;
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
- padding: 12px 20px;
- display: flex;
- .typeContainer {
- }
- .typeBox {
- height: 80px;
- width: 80px;
- border-radius: 4px 4px 4px 4px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .icon {
- height: 32px;
- width: 32px;
- }
- .name {
- width: 56px;
- height: 16px;
- font-weight: 500;
- font-size: 14px;
- line-height: 16px;
- text-align: center;
- font-style: normal;
- text-transform: none;
- }
- }
- .addBtn {
- border: 1px solid #0a59f7;
- color: #0a59f7;
- }
- .others {
- color: rgba(0, 0, 0, 0.9);
- border: 1px solid rgba(0, 0, 0, 0.9);
- margin-left: 20px;
- position: relative;
- }
- .delete {
- //position: absolute;
- //bottom: -20px;
- //left: 0;
- margin-left: 50px;
- width: 1em;
- height: 1em;
- color: red;
- visibility: hidden;
- }
- .typeContainer:hover {
- .delete {
- visibility: visible;
- }
- }
- .normal {
- background: #ffffff;
- border: 1px solid rgba(35, 32, 50, 0.1);
- }
- .selected {
- background: rgba(10, 89, 247, 0.2);
- border: 1px solid #0a59f7;
- }
- }
- .title {
- line-height: 44px;
- color: #6f7991;
- font-size: 14px;
- font-weight: bold;
- text-align: left;
- margin-left: 20px;
- }
- .binContainer {
- height: calc(100vh - 280px);
- width: 100%;
- background-color: #f5f7f9;
- overflow-y: auto;
- background-color: white;
- //margin-top: 16px;
- //margin-left: 20px;
- padding: 16px 20px;
- }
- .tipTitle {
- width: 84px;
- height: 16px;
- font-weight: 500;
- font-size: 14px;
- color: rgba(0, 0, 0, 0.9);
- line-height: 16px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- margin-bottom: 16px;
- }
- </style>
|