123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- <!-- 批量新增 -->
- <script>
- import useColumns from "./column";
- import {
- addChangeList,
- getMaterialDetails,
- getChangeDetails,
- editChangeList,
- importInner,
- saveAndSubmit,
- } from "@/api/changeApply/basic";
- import { REFER } from "@/components/popover-select/api";
- export default {
- name: "AddChangeOrders",
- props: {
- dict: {
- type: Object,
- },
- addType: {
- type: String,
- default: "add",
- },
- },
- components: {
- AmendantRecord: () => import("../amendantRecord/index.vue"),
- ElSuperForm: () => import("@/components/super-form/index.vue"),
- ElSuperTable: () => import("@/components/super-table/index.vue"),
- ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
- ElPopoverTreeSelect: () =>
- import("@/components/popover-tree-select/index.vue"),
- BatchImport: () => import("@/components/BatchImport/index.vue"),
- ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
- },
- data() {
- const {
- TabColumns,
- TableColumns,
- TabColumns: [
- {
- item: { key: tabName },
- },
- ],
- } = useColumns();
- const rules = this.$init.rules([...TabColumns, ...TableColumns]);
- const params = this.$init.params([...TabColumns, ...TableColumns]);
- return {
- width: "100%",
- visible: false,
- loading: false,
- rules,
- params,
- tabName: tabName,
- TabColumns: TabColumns,
- TableColumns: TableColumns,
- };
- },
- computed: {
- title: {
- get() {
- const { addType } = this;
- if (addType === "add") {
- return "新 增";
- }
- if (addType === "edit") {
- return "编 辑";
- }
- },
- set() {},
- },
- materialInfo: {
- get() {
- const { materialBasic } = this.params;
- this.params.materialBasic = materialBasic.map((item, index) => ({
- ...item,
- $index: index,
- }));
- return {
- materialBasic: this.params.materialBasic.filter(
- ({ delFlag }) => delFlag !== "2"
- ),
- };
- },
- set() {},
- },
- },
- watch: {},
- methods: {
- setVisible(prop) {
- this.visible = prop;
- },
- beforeOpen() {
- if (this.addType === "add") {
- let { name, nickName } = this.$store.state.user;
- this.params.createBy = name;
- this.params.createByName = nickName;
- this.params.createTime = new Date().Format("yyyy-MM-dd HH:mm:ss");
- this.params.updateBy = name;
- this.params.updateByName = nickName;
- this.params.updateTime = new Date().Format("yyyy-MM-dd HH:mm:ss");
- // this.params.approver = name;
- this.params.applicationTime = new Date().Format("yyyy-MM-dd HH:mm:ss");
- this.params.status = "0";
- console.log(this.$store.state.user, "user");
- this.params.orgName = "德荣集团";
- // this.useRowAdd(this.tabName);
- }
- },
- //
- async fetchItem(prop) {
- try {
- // try
- this.loading = true;
- let { code, data } = await getChangeDetails(prop.id);
- if (code == 200) {
- this.params = data;
- }
- } catch (err) {
- // catch
- console.error(err);
- } finally {
- // finally
- this.loading = false;
- }
- },
- //
- async hide() {
- const {
- TabColumns,
- TableColumns,
- TabColumns: [
- {
- item: { key: tabName },
- },
- ],
- } = useColumns();
- this.visible = false;
- this.$emit("success");
- this.tabName = tabName;
- this.params = this.$init.params([...TabColumns, ...TableColumns]);
- },
- //
- async useRowAdd(prop) {
- const { TableColumns } = this.TabColumns.find(
- ({ item: { key } }) => key === prop
- );
- this.params[prop].push({
- delFlag: "0",
- materialClassifyId: null,
- ...this.$init.params(TableColumns),
- });
- },
- //
- async useRowRemove(prop, scope) {
- const { addType } = this.$props;
- const {
- row: { $index },
- } = scope;
- if (addType === "add") {
- this.params[prop].splice($index, 1);
- }
- if (addType === "edit") {
- this.params[prop] = this.params[prop]
- .map((item, index) => ({
- ...item,
- delFlag: index === $index ? "2" : item.delFlag,
- }))
- .filter((item) => item.id || (!item.id && item.delFlag === "0"));
- }
- },
- handleSubmitValidate(prop, cb) {
- this.$refs[prop].$refs[prop].validate(async (valid) => {
- if (valid) {
- try {
- this.loading = true;
- let validList = this.params["materialBasic"].filter(
- (item) => item.delFlag === "0"
- );
- if (validList.length) {
- await cb();
- } else {
- this.$notify.error({
- message: "物料信息不能不为空!",
- });
- }
- } catch (err) {
- // catch
- console.error(err);
- } finally {
- // finally
- this.loading = false;
- }
- } else {
- return false;
- }
- });
- },
- //
- async useSave(prop) {
- let params = _.cloneDeep(this.params);
- this.handleSubmitValidate(prop, async () => {
- try {
- this.loading = true;
- const { code, msg } = await addChangeList(params);
- if (code == 200) {
- this.hide();
- this.$notify.success({
- title: msg,
- });
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- // await;
- });
- },
- // 保存并提交
- async useSubmit(prop) {
- let params = _.cloneDeep(this.params);
- console.log(params, "params");
- this.handleSubmitValidate(prop, async () => {
- try {
- this.loading = true;
- const { code, msg } = await saveAndSubmit({
- ...params,
- isInventory: "Y",
- });
- if (code == 200) {
- this.hide();
- this.$notify.success({
- title: msg,
- });
- } else if (code == 10000) {
- this.$alert(
- "<div style='overflow: auto;overflow-x: hidden;max-height: 65vh;padding: 10px 20px 0;'>" +
- msg +
- "</div>",
- "提示",
- {
- showCancelButton: true,
- dangerouslyUseHTMLString: true,
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- beforeClose: async (action, instance, done) => {
- if (action === "confirm") {
- instance.confirmButtonLoading = true;
- instance.confirmButtonText = "执行中...";
- try {
- const { code, msg } = await saveAndSubmit({
- ...params,
- isInventory: "N",
- });
- if (code == 200) {
- done();
- this.hide();
- this.$notify.success({
- message: msg,
- });
- }
- } catch (error) {
- instance.confirmButtonText = "确认";
- } finally {
- instance.confirmButtonLoading = false;
- }
- } else {
- done();
- this.$notify.warning({
- message:
- "不允许修改【批号及库存状态管理】或【是否序列号管理】",
- });
- }
- },
- }
- );
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- });
- },
- async handelImport(fileList) {
- try {
- let formData = new FormData();
- formData.append("file", fileList[0].raw);
- this.$modal.loading("正在上传文件,请稍候...");
- let { code, data } = await importInner(formData);
- if (code == 200) {
- // let size = 20;
- // let num = 1;
- // let total = Math.ceil(data.length / size);
- // let resultData = [...data];
- // let intervalPush = setInterval(()=>{
- // if(num > total) clearInterval(intervalPush);
- // resultData.slice(size*(num-1), (size*num) ).forEach(item =>{
- // this.params['materialBasic'].push(item);
- this.params["materialBasic"].push(...data);
- // })
- // num++;
- // },200);
- let { setVisible } = this.$refs.batchImport;
- setVisible(false);
- }
- } catch (error) {
- } finally {
- this.$modal.closeLoading();
- }
- },
- async handleTemDownload() {
- this.download(
- "/material/change/downloadInner",
- {},
- `变更单物料信息模板${new Date().getTime()}.xlsx`
- );
- },
- // 批号及库存状态管理
- changeIsInventoryStatus(row) {
- if (row.isInventoryStatus === "2") {
- row.expiryDateManagerment = "2";
- row.serialNoManager = "2";
- }
- this.changeExpiryDateManagerment(row);
- },
- changeExpiryDateManagerment(row) {
- if (row.expiryDateManagerment === "2") {
- row.usefulLife = "";
- row.expiryUnitId = "";
- row.usefulLifeUnitId = "";
- row.nearOnsetManagerment = "2";
- row.recentWarningPeriod = "";
- }
- },
- // 物料编码
- async materialCodeChange(prop) {
- let { factory } = prop;
- try {
- // this.loading = true;
- let { code, rows } = await REFER(
- {
- type: "MANUFACTURER_PARAM",
- search: "",
- id: factory,
- isPage: true,
- },
- { pageNum: 1, pageSize: 10 }
- );
- if (rows[0]) {
- let { manufacturerOther } = rows[0];
- prop["brand"] = manufacturerOther.brand;
- }
- } catch (error) {
- } finally {
- // this.loading = false;
- }
- },
- },
- created() {},
- mounted() {},
- destroyed() {},
- };
- </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
- type="primary"
- :size="$attrs.size"
- :loading="loading"
- @click="useSave('superForm')"
- >保 存</el-button
- >
- <el-button
- type="primary"
- :size="$attrs.size"
- :loading="loading"
- @click="useSubmit('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="TableColumns"
- ref="superForm"
- label-width="auto"
- label-position="right"
- style="padding: 20px"
- >
- <template slot="puOrgName" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- >
- </component
- ></template>
- </el-super-form>
- <div style="position: relative">
- <el-tabs v-model="tabName" style="padding: 0 20px 20px">
- <el-tab-pane
- v-for="({ item, TableColumns: columns }, index) in TabColumns"
- :key="index"
- :label="item.title"
- :name="item.key"
- lazy
- >
- <el-super-ux-table
- index
- v-model="materialInfo[item.key]"
- :dict="dict"
- :ref="tabName"
- :columns="columns"
- :size="$attrs.size"
- :height="420"
- >
- <template slot="materialCode" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- @change="materialCodeChange(scope.row)"
- >
- </component>
- </template>
- <template slot="materialName" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- >
- </component>
- </template>
- <!-- 判断是否禁用 -->
- <template slot="drug" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="!(scope.row.medicineMaterial === '0')"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <template slot="registrationNo" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="!(scope.row.medicineMaterial === '0')"
- >
- </component>
- </template>
- <template slot="medicalDevices" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="!(scope.row.medicineMaterial === '0')"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <template slot="maintenanceType" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="!(scope.row.medicineMaterial === '0')"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <!-- <template slot="dosageFromName" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="!(scope.row.medicineMaterial ==='0') "
- >
- </component>
- </template> -->
- <!-- 批号及库存状态管理 -->
- <template slot="isInventoryStatus" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- @change="changeIsInventoryStatus(scope.row)"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <!-- 效期管理 -->
- <template slot="expiryDateManagerment" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="scope.row.isInventoryStatus !== '0'"
- @change="changeExpiryDateManagerment(scope.row)"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <!-- 是否序列号管理 -->
- <template slot="serialNoManager" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="scope.row.isInventoryStatus !== '0'"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <!-- 有效期 -->
- <template slot="usefulLife" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="scope.row.expiryDateManagerment !== '0'"
- >
- </component>
- </template>
- <!-- 效期单位 -->
- <template slot="expiryUnitId" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="scope.row.expiryDateManagerment !== '0'"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <!-- 有效期至单位 -->
- <template slot="usefulLifeUnitId" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="scope.row.expiryDateManagerment !== '0'"
- >
- <el-option
- v-for="item in dict.type[scope.attr.dictName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </component>
- </template>
- <!-- 近效期预警天数 -->
- <template slot="recentWarningPeriod" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="scope.row.expiryDateManagerment !== '0'"
- >
- </component>
- </template>
- <ux-table-column
- fixed="right"
- title="操作"
- width="120"
- align="center"
- >
- <template slot="header" slot-scope="scope">
- <el-button
- type="text"
- :size="$attrs.size"
- @click="useRowAdd(tabName)"
- >
- 增行
- </el-button>
- </template>
- <template slot-scope="scope">
- <el-button
- type="text"
- :size="$attrs.size"
- @click.native.prevent="useRowRemove(tabName, scope)"
- >
- 删除
- </el-button>
- <AmendantRecord
- v-if="
- tabName === 'materialBasic' &&
- addType === 'edit' &&
- scope.row.id
- "
- v-model="scope.row"
- ></AmendantRecord>
- </template>
- </ux-table-column>
- </el-super-ux-table>
- </el-tab-pane>
- </el-tabs>
- <el-row style="position: absolute; top: 0px; right: 20px">
- <BatchImport
- ref="batchImport"
- @import="handelImport"
- @temDownload="handleTemDownload"
- ></BatchImport>
- </el-row>
- </div>
- </el-drawer>
- </template>
- <style scoped>
- ::v-deep .el-table__row.is-hidden {
- display: none;
- }
- </style>
|