|
@@ -5,95 +5,102 @@
|
|
|
</div>
|
|
|
<el-cascader
|
|
|
ref="ElCascaderRef"
|
|
|
- v-model="contractId" class="hc-header-cascader"
|
|
|
+ v-model="contractId"
|
|
|
+ class="hc-header-cascader"
|
|
|
:clearable="userInfo?.role_id === '1123598816738675201'"
|
|
|
:filterable="userInfo?.role_id === '1123598816738675201'"
|
|
|
:options="projectContract"
|
|
|
- :props="projectProps" placeholder="请选择项目"
|
|
|
+ :props="projectProps"
|
|
|
+ placeholder="请选择项目"
|
|
|
@change="projectContractChange"
|
|
|
/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref, watch } from 'vue'
|
|
|
-import { useAppStore } from '~src/store'
|
|
|
-import { initProjectContract } from '~sto/app'
|
|
|
-import { isNullES } from 'js-fast-way'
|
|
|
+import { onMounted, ref, watch } from "vue";
|
|
|
+import { useAppStore } from "~src/store";
|
|
|
+import { initProjectContract } from "~sto/app";
|
|
|
+import { isNullES } from "js-fast-way";
|
|
|
|
|
|
//事件
|
|
|
-const emit = defineEmits(['change', 'send'])
|
|
|
+const emit = defineEmits(["change", "send"]);
|
|
|
|
|
|
//状态
|
|
|
-const store = useAppStore()
|
|
|
-const userInfo = ref(store.getUserInfo)
|
|
|
+const store = useAppStore();
|
|
|
+const userInfo = ref(store.getUserInfo);
|
|
|
|
|
|
const projectProps = ref({
|
|
|
- value: 'id',
|
|
|
- label: 'projectAlias',
|
|
|
- children: 'contractInfoList',
|
|
|
-})
|
|
|
+ value: "id",
|
|
|
+ label: "projectAlias",
|
|
|
+ children: "contractInfoList",
|
|
|
+});
|
|
|
|
|
|
//项目合同段
|
|
|
-const projectContract = ref(store.projectContract)
|
|
|
-const projectInfo = ref(store.projectInfo)
|
|
|
-const contractInfo = ref(store.contractInfo)
|
|
|
-const contractId = ref(store.contractId)
|
|
|
+const projectContract = ref(store.projectContract);
|
|
|
+const projectInfo = ref(store.projectInfo);
|
|
|
+const contractInfo = ref(store.contractInfo);
|
|
|
+const contractId = ref(store.contractId);
|
|
|
|
|
|
//监听
|
|
|
-watch(() => [
|
|
|
- store.projectContract,
|
|
|
- store.projectInfo,
|
|
|
- store.contractInfo,
|
|
|
- store.projectId,
|
|
|
- store.contractId,
|
|
|
-], ([arr, project, contract, pid, cid]) => {
|
|
|
- projectContract.value = arr
|
|
|
- projectInfo.value = project
|
|
|
- contractInfo.value = contract
|
|
|
- contractId.value = cid
|
|
|
- setSend(pid, cid)
|
|
|
-})
|
|
|
+watch(
|
|
|
+ () => [
|
|
|
+ store.projectContract,
|
|
|
+ store.projectInfo,
|
|
|
+ store.contractInfo,
|
|
|
+ store.projectId,
|
|
|
+ store.contractId,
|
|
|
+ ],
|
|
|
+ ([arr, project, contract, pid, cid]) => {
|
|
|
+ projectContract.value = arr;
|
|
|
+ projectInfo.value = project;
|
|
|
+ contractInfo.value = contract;
|
|
|
+ contractId.value = cid;
|
|
|
+ setSend(pid, cid);
|
|
|
+ }
|
|
|
+);
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(async () => {
|
|
|
- await initProjectContract()
|
|
|
- setSend(store.projectId, store.contractId)
|
|
|
-})
|
|
|
+ await initProjectContract();
|
|
|
+ setSend(store.projectId, store.contractId);
|
|
|
+});
|
|
|
|
|
|
const setSend = (pid, cid) => {
|
|
|
if (isNullES(pid) || isNullES(cid)) {
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
- emit('send', {
|
|
|
+ emit("send", {
|
|
|
projectId: pid,
|
|
|
contractId: cid,
|
|
|
- })
|
|
|
-}
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
//项目被选择
|
|
|
-const ElCascaderRef = ref(null)
|
|
|
+const ElCascaderRef = ref(null);
|
|
|
const projectContractChange = (val) => {
|
|
|
if (val) {
|
|
|
- const Nodes = ElCascaderRef.value.getCheckedNodes()
|
|
|
- const UserProjectInfo = Nodes[0].parent.data
|
|
|
- const UserContractInfo = Nodes[0].data
|
|
|
+ const Nodes = ElCascaderRef.value.getCheckedNodes();
|
|
|
+ const UserProjectInfo = Nodes[0].parent.data;
|
|
|
+ const UserContractInfo = Nodes[0].data;
|
|
|
//缓存项目数据
|
|
|
- store.setProjectId(val[0])
|
|
|
- store.setContractId(val[1])
|
|
|
- store.setProjectInfo(UserProjectInfo)
|
|
|
- store.setContractInfo(UserContractInfo)
|
|
|
+ store.setProjectId(val[0]);
|
|
|
+ store.setContractId(val[1]);
|
|
|
+ store.setProjectInfo(UserProjectInfo);
|
|
|
+ store.setContractInfo(UserContractInfo);
|
|
|
//更改界面更新
|
|
|
- projectInfo.value = UserProjectInfo
|
|
|
- contractInfo.value = UserContractInfo
|
|
|
- window.$message?.info('切换了项目,数据更新中')
|
|
|
- emit('send', {
|
|
|
+ projectInfo.value = UserProjectInfo;
|
|
|
+ contractInfo.value = UserContractInfo;
|
|
|
+ window.$message?.info("切换了项目,数据更新中");
|
|
|
+
|
|
|
+ emit("send", {
|
|
|
projectId: val[0],
|
|
|
contractId: val[1],
|
|
|
- })
|
|
|
- emit('change')
|
|
|
+ });
|
|
|
+ emit("change");
|
|
|
+ window?.location?.reload(); //刷新页面
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|