|
@@ -1,141 +1,25 @@
|
|
|
<script>
|
|
|
+import { add } from "@/api/business/purchase/purchase-contract";
|
|
|
+import { arr2obj } from "@/utils/data-transform";
|
|
|
+import {
|
|
|
+ initDicts,
|
|
|
+ initRules,
|
|
|
+ initParams,
|
|
|
+ initComponents,
|
|
|
+} from "@/utils/init-something";
|
|
|
+import { initColumns } from "./config/add";
|
|
|
+
|
|
|
export default {
|
|
|
name: "AddPurchaseTaskDrawer",
|
|
|
+ // components: initComponents(initColumns()),
|
|
|
+ dicts: initDicts(initColumns()),
|
|
|
data() {
|
|
|
- const arr2Obj = function (data, keyName, valueName) {
|
|
|
- return Object.fromEntries(
|
|
|
- data.map((item) => [item[keyName], item[valueName]])
|
|
|
- );
|
|
|
- };
|
|
|
- const pickerOptions = {
|
|
|
- disabledDate(time) {
|
|
|
- return time.getTime() > Date.now();
|
|
|
- },
|
|
|
- shortcuts: [
|
|
|
- {
|
|
|
- text: "今天",
|
|
|
- onClick(picker) {
|
|
|
- picker.$emit("pick", new Date());
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- text: "昨天",
|
|
|
- onClick(picker) {
|
|
|
- const date = new Date();
|
|
|
- date.setTime(date.getTime() - 3600 * 1000 * 24);
|
|
|
- picker.$emit("pick", date);
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- text: "一周前",
|
|
|
- onClick(picker) {
|
|
|
- const date = new Date();
|
|
|
- date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
|
|
- picker.$emit("pick", date);
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- const columns = [
|
|
|
- {
|
|
|
- title: "采购组织",
|
|
|
- key: "puOrg",
|
|
|
- type: "TagSelect",
|
|
|
- value: [],
|
|
|
- required: true,
|
|
|
- },
|
|
|
- { title: "需求来源", key: "source", type: "Input", value: "采购创建" },
|
|
|
- { title: "采购员", key: "buyer", value: [], type: "TagSelect" },
|
|
|
- { title: "交易类型", key: "billYpe", value: [], type: "TagSelect" },
|
|
|
- { title: "物料编码", key: "material", type: "Input", required: true },
|
|
|
- {
|
|
|
- title: "物料名称",
|
|
|
- key: "materialName",
|
|
|
- type: "TagSelect",
|
|
|
- value: [],
|
|
|
- required: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: "物料/物料描述",
|
|
|
- key: "materialDesc",
|
|
|
- type: "TagSelect",
|
|
|
- value: [],
|
|
|
- required: true,
|
|
|
- },
|
|
|
- { title: "生产厂家", key: "manufacturer", type: "Input" },
|
|
|
- { title: "收货客户", key: "customer", type: "TagSelect", value: [] },
|
|
|
- {
|
|
|
- title: "采购单位",
|
|
|
- key: "puUnit",
|
|
|
- type: "TagSelect",
|
|
|
- value: [],
|
|
|
- required: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: "采购数量",
|
|
|
- key: "puQty",
|
|
|
- type: "InputNumber",
|
|
|
- required: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: "需求时间",
|
|
|
- key: "demandDate",
|
|
|
- type: "DatePicker",
|
|
|
- config: { type: "date", pickerOptions: pickerOptions },
|
|
|
- },
|
|
|
- { title: "项目名称", key: "projectName", type: "TagSelect", value: [] },
|
|
|
- { title: "需求人", key: "demandPersonal", type: "TagSelect", value: [] },
|
|
|
- {
|
|
|
- title: "需求组织",
|
|
|
- key: "demandOrg",
|
|
|
- type: "TagSelect",
|
|
|
- value: [],
|
|
|
- require: true,
|
|
|
- },
|
|
|
- { title: "需求部门", key: "demandDept", type: "TagSelect", value: [] },
|
|
|
- { title: "建议供应商", key: "supplier", type: "TagSelect", value: [] },
|
|
|
- { title: "收货人", key: "a", type: "TagSelect", value: [] },
|
|
|
- { title: "收货组织", key: "b", type: "TagSelect", value: [] },
|
|
|
- { title: "收货人联系方式", key: "c", type: "Input" },
|
|
|
- { title: "收货地址", key: "d", type: "Input" },
|
|
|
- { title: "收货仓库", key: "e", type: "TagSelect", value: [] },
|
|
|
- {
|
|
|
- title: "指定供应商",
|
|
|
- key: "assignSupplier",
|
|
|
- type: "TagSelect",
|
|
|
- value: [],
|
|
|
- },
|
|
|
- { title: "单位", key: "unit", type: "TagSelect", value: [] },
|
|
|
- { title: "收货地址", key: "f", type: "TagSelect", value: [] },
|
|
|
- ];
|
|
|
- const initColumns = () => columns;
|
|
|
- const initParams = () => arr2Obj(initColumns(), "key", "value");
|
|
|
return {
|
|
|
visible: false,
|
|
|
columns: initColumns(),
|
|
|
- params: initParams(),
|
|
|
- options: [
|
|
|
- {
|
|
|
- value: "选项1",
|
|
|
- label: "黄金糕",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "选项2",
|
|
|
- label: "双皮奶",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "选项3",
|
|
|
- label: "蚵仔煎",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "选项4",
|
|
|
- label: "龙须面",
|
|
|
- },
|
|
|
- {
|
|
|
- value: "选项5",
|
|
|
- label: "北京烤鸭",
|
|
|
- },
|
|
|
- ],
|
|
|
+ rules: initRules(initColumns()),
|
|
|
+ params: initParams(initColumns()),
|
|
|
+ currentComponent: { name: "", title: "", value: "", row: {} },
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
@@ -144,6 +28,40 @@ export default {
|
|
|
setVisible(prop) {
|
|
|
this.visible = prop;
|
|
|
},
|
|
|
+ //
|
|
|
+ openAsyncInputDialog(prop, type) {
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ key,
|
|
|
+ title,
|
|
|
+ config: { componentName },
|
|
|
+ } = prop;
|
|
|
+ this.currentComponent.row = prop;
|
|
|
+ this.currentComponent.title = title;
|
|
|
+ this.currentComponent.name = componentName;
|
|
|
+ if (type === "change") {
|
|
|
+ this.currentComponent.value = this.params[key];
|
|
|
+ }
|
|
|
+ if (type === "click") {
|
|
|
+ this.currentComponent.value = "";
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const { setVisible } = this.$refs[componentName];
|
|
|
+ setVisible(true);
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ this.$notify.error({ title: "error", message: err });
|
|
|
+ } finally {
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateParams(prop) {
|
|
|
+ const {
|
|
|
+ config: { dataMapping },
|
|
|
+ } = this.currentComponent.row;
|
|
|
+ for (let key in dataMapping) {
|
|
|
+ this.params[key] = prop[dataMapping[key]];
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
console.log(this.params);
|
|
@@ -154,104 +72,178 @@ export default {
|
|
|
</script>
|
|
|
<template>
|
|
|
<el-drawer
|
|
|
- title="我是标题"
|
|
|
direction="btt"
|
|
|
size="100%"
|
|
|
:with-header="false"
|
|
|
:visible.sync="visible"
|
|
|
- :before-close="handleClose"
|
|
|
+ @open="beforeOpen"
|
|
|
>
|
|
|
- <el-form
|
|
|
- size="mini"
|
|
|
- label-position="right"
|
|
|
- label-width="125px"
|
|
|
- :model="params"
|
|
|
+ <el-card
|
|
|
+ :body-style="{
|
|
|
+ padding: '20px',
|
|
|
+ display: 'flex',
|
|
|
+ 'flex-wrap': 'wrap',
|
|
|
+ }"
|
|
|
+ style="margin: 10px"
|
|
|
>
|
|
|
- <el-card
|
|
|
- :body-style="{
|
|
|
- padding: '20px',
|
|
|
- display: 'flex',
|
|
|
- 'flex-wrap': 'wrap',
|
|
|
- }"
|
|
|
- style="margin: 10px"
|
|
|
- >
|
|
|
- <el-form-item
|
|
|
- v-for="(column, index) in columns"
|
|
|
- :key="index"
|
|
|
- :prop="column.key"
|
|
|
- :label="column.title"
|
|
|
- :required="column.required"
|
|
|
- style="width: 33%"
|
|
|
- >
|
|
|
- <el-input
|
|
|
- v-if="column.type === 'Input'"
|
|
|
- v-model="params[column.key]"
|
|
|
- :placeholder="column.placeholder"
|
|
|
- style="width: 90%"
|
|
|
- ></el-input>
|
|
|
- <el-input-number
|
|
|
- v-if="column.type === 'InputNumber'"
|
|
|
- v-model="params[column.key]"
|
|
|
- controls-position="right"
|
|
|
- :placeholder="column.placeholder"
|
|
|
- style="width: 90%"
|
|
|
- ></el-input-number>
|
|
|
- <el-select
|
|
|
- v-if="column.type === 'TagSelect'"
|
|
|
- v-model="params[column.key]"
|
|
|
- multiple
|
|
|
- clearable
|
|
|
- collapse-tags
|
|
|
- :placeholder="column.placeholder"
|
|
|
- style="width: 90%"
|
|
|
- >
|
|
|
- <template #prefix>
|
|
|
- <el-icon
|
|
|
- class="el-icon-s-operation"
|
|
|
- style="cursor: pointer"
|
|
|
- @click.stop="$message.info(234)"
|
|
|
- ></el-icon>
|
|
|
- </template>
|
|
|
- <el-option
|
|
|
- v-for="item in options"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- <el-date-picker
|
|
|
- v-if="column.type === 'DatePicker'"
|
|
|
- v-model="params[column.key]"
|
|
|
- :type="column.config.type"
|
|
|
- :placeholder="column.placeholder"
|
|
|
- :picker-options="column.pickerOptions"
|
|
|
- style="width: 90%"
|
|
|
- >
|
|
|
- </el-date-picker>
|
|
|
- </el-form-item>
|
|
|
- </el-card>
|
|
|
- <el-card
|
|
|
- :body-style="{
|
|
|
- 'text-align': 'right',
|
|
|
- padding: '10px 20px',
|
|
|
- }"
|
|
|
+ <div
|
|
|
+ slot="header"
|
|
|
style="
|
|
|
- position: fixed;
|
|
|
- left: 0;
|
|
|
- bottom: 0;
|
|
|
- margin: 10px;
|
|
|
- width: calc(100% - 20px);
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
"
|
|
|
>
|
|
|
- <el-button size="mini" @click="setVisible(false)">取消</el-button>
|
|
|
- <el-button size="mini" type="info" @click="setVisible(false)"
|
|
|
- >保存并新增</el-button
|
|
|
+ <h3>新增</h3>
|
|
|
+ <div style="text-align: right">
|
|
|
+ <el-button size="mini" @click="cancel">取消</el-button>
|
|
|
+ <el-button size="mini" type="danger" @click="sava">保存</el-button>
|
|
|
+ <el-button size="mini" type="info" @click="submitSava">
|
|
|
+ 保存并新增
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <component
|
|
|
+ v-if="currentComponent.name"
|
|
|
+ :is="currentComponent.name"
|
|
|
+ :ref="currentComponent.name"
|
|
|
+ :title="currentComponent.title"
|
|
|
+ :value="currentComponent.value"
|
|
|
+ @confirm="updateParams"
|
|
|
+ ></component>
|
|
|
+ <el-row>
|
|
|
+ <el-form
|
|
|
+ size="mini"
|
|
|
+ label-position="right"
|
|
|
+ label-width="135px"
|
|
|
+ :model="params"
|
|
|
+ :rules="rules"
|
|
|
>
|
|
|
- <el-button size="mini" type="danger" @click="setVisible(false)"
|
|
|
- >保存</el-button
|
|
|
- >
|
|
|
- </el-card>
|
|
|
- </el-form>
|
|
|
+ <el-col
|
|
|
+ v-for="(column, index) in columns"
|
|
|
+ :key="index"
|
|
|
+ :span="column.span || 6"
|
|
|
+ >
|
|
|
+ <el-form-item :prop="column.key" :label="column.title">
|
|
|
+ <el-input
|
|
|
+ v-if="column.type === 'Input'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ ></el-input>
|
|
|
+ <el-input
|
|
|
+ v-if="column.type === 'InputDialog'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ @blur="openAsyncInputDialog(column, 'change')"
|
|
|
+ @change="openAsyncInputDialog(column, 'change')"
|
|
|
+ >
|
|
|
+ <template #suffix>
|
|
|
+ <el-icon
|
|
|
+ class="el-icon-s-operation"
|
|
|
+ style="cursor: pointer"
|
|
|
+ @click.native.stop="openAsyncInputDialog(column, 'click')"
|
|
|
+ ></el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ <el-input
|
|
|
+ v-if="column.type === 'Textarea'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ type="textarea"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ ></el-input>
|
|
|
+ <el-input-number
|
|
|
+ v-if="column.type === 'InputNumber'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ :controls-position="
|
|
|
+ column.config && column.config.controlsPosition
|
|
|
+ "
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ ></el-input-number>
|
|
|
+ <el-select
|
|
|
+ v-if="column.type === 'Select'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in dict.type[column.config.optionsName]"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-select
|
|
|
+ v-if="column.type === 'TagSelect'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ multiple
|
|
|
+ clearable
|
|
|
+ collapse-tags
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon
|
|
|
+ class="el-icon-s-operation"
|
|
|
+ style="cursor: pointer"
|
|
|
+ @click.stop="$message.info(234)"
|
|
|
+ ></el-icon>
|
|
|
+ </template>
|
|
|
+ <el-option
|
|
|
+ v-for="item in options"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-date-picker
|
|
|
+ v-if="column.type === 'DatePicker'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ :type="column.config.type"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ :picker-options="column.pickerOptions"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ <el-upload
|
|
|
+ v-if="column.type === 'Upload'"
|
|
|
+ :file-list="params[column.key]"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ drag
|
|
|
+ action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
+ multiple
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text">
|
|
|
+ 将文件拖到此处,或<em>点击上传</em>
|
|
|
+ </div>
|
|
|
+ <div class="el-upload__tip" slot="tip">
|
|
|
+ 只能上传jpg/png文件,且不超过500kb
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </el-row>
|
|
|
+ </el-card>
|
|
|
</el-drawer>
|
|
|
</template>
|