123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <!-- 采购员上级采购经理匹配——详情 -->
- <script>
- import useColumns from "./columns";
- import { ADD, DETAILS, EDIT } from "@/api/business/purchase/match";
- export default {
- name: "MatchDetails",
- props: {
- dict: {
- type: Object,
- },
- addType: {
- type: String,
- default: "add",
- },
- data: {
- type: Array,
- default: () => [],
- },
- },
- components: {
- ElSuperForm: () => import("@/components/super-form/index.vue"),
- ElPopoverMultipleTreeSelect: () =>
- import("@/components/popover-tree-select/multiple.vue"),
- },
- data() {
- const { FormColumns } = useColumns();
- const params = this.$init.params(FormColumns);
- const rules = this.$init.rules(FormColumns);
- return {
- rules,
- params: {
- ...params,
- enable: "0",
- },
- FormColumns,
- width: "100%",
- visible: false,
- loading: false,
- };
- },
- computed: {
- title: {
- get() {
- const { addType } = this;
- if (addType === "add") {
- return "新 增";
- }
- if (addType === "edit") {
- return "编 辑";
- }
- return "查 看";
- },
- set() {},
- },
- innerValue: {
- get() {
- let { data } = this.$props;
- return data.length ? data[0] : null;
- },
- set() {},
- },
- },
- methods: {
- setVisible(prop) {
- this.visible = prop;
- },
- //
- async fetchItem(id) {
- try {
- this.loading = true;
- let { code, msg, data } = await DETAILS({ id });
- if (code === 200) {
- this.params = data;
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- },
- beforeOpen() {
- let {
- $props: { addType },
- innerValue,
- } = this;
- if (addType !== "add") {
- this.fetchItem(innerValue.id);
- }
- },
- hide() {
- this.visible = false;
- this.params = { ...this.$init.params(this.FormColumns), enable: "0" };
- this.$emit("refresh");
- },
- useSave(prop) {
- console.log(this.params,"params");
- this.$refs[prop].$refs[prop].validate(async (valid) => {
- if (valid) {
- try {
- this.loading = true;
- let {
- $props: { addType },
- params,
- } = this;
- let { code, msg } =
- addType === "edit"
- ? await EDIT({ ...params })
- : await ADD({ ...params });
- if (code === 200) {
- this.$notify.success(msg);
- this.hide();
- }
- } catch (err) {
- console.error(err);
- } finally {
- this.loading = false;
- }
- } else {
- return false;
- }
- });
- },
- },
- created() {},
- };
- </script>
- <template>
- <el-drawer
- v-bind="$attrs"
- v-on="$listeners"
- :size="width"
- :visible.sync="visible"
- destroy-on-close
- :show-close="false"
- @close="hide"
- @open="beforeOpen"
- v-loading="loading"
- >
- <div
- slot="title"
- style="display: flex; justify-content: space-between; align-items: center"
- >
- <h3>{{ title }}</h3>
- <div>
- <el-button
- v-show="addType !== 'see'"
- type="primary"
- :size="$attrs.size"
- :loading="loading"
- @click="useSave('superForm')"
- >保 存</el-button
- >
- <el-button :size="$attrs.size" :loading="loading" @click="hide"
- >取 消</el-button
- >
- </div>
- </div>
- <el-super-form
- v-model="params"
- :dict="dict"
- :rules="rules"
- :size="$attrs.size"
- :columns="FormColumns"
- ref="superForm"
- label-width="auto"
- label-position="right"
- style="padding: 20px"
- :disabled="addType === 'see'"
- >
- <template slot="classOneObjectList" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :closable="addType !== 'see'"
- >
- </component
- ></template>
- </el-super-form>
- </el-drawer>
- </template>
- <style scoped>
- >>> .el-drawer__header {
- margin-bottom: 0;
- padding: 5px 20px;
- }
- </style>
|