123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- <script>
- import useColumns from "./columns";
- import {
- addReq,
- getReqDetail,
- editReq,
- saveAndToOa,
- betchSubmit,
- } from "@/api/requisition/basic";
- import { REFER } from "@/components/popover-select/api/index";
- export default {
- name: "AddRequsition",
- props: {
- dict: {
- type: [Object, Array],
- },
- addType: {
- type: String,
- default: "add",
- },
- },
- components: {
- ElSuperForm: () => import("@/components/super-form/index.vue"),
- ElSuperTable: () => import("@/components/super-table/index.vue"),
- ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
- ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
- ElPopoverTreeSelect: () =>
- import("@/components/popover-tree-select/index.vue"),
- },
- data() {
- const {
- MaterialColums,
- TabColumns,
- TabColumns: [
- {
- item: { key: tabName },
- },
- ],
- } = useColumns();
- let rules = TabColumns.reduce((pre, cur) => {
- pre = {
- ...pre,
- ...this.$init.rules([...cur.TableColumns]),
- };
- return pre;
- }, {});
- const sysMaterialApply = this.$init.params([
- ...TabColumns.find(({ item }) => item.key === "sysMaterialApply")
- .TableColumns,
- ]);
- const sysMaterialMedcineApply = this.$init.params([
- ...TabColumns.find(({ item }) => item.key === "sysMaterialMedcineApply")
- .TableColumns,
- ]);
- const applyBillInfo = this.$init.params([
- ...TabColumns.find(({ item }) => item.key === "applyBillInfo")
- .TableColumns,
- ]);
- const materialReference = this.$init.params([...MaterialColums]);
- return {
- width: "100%",
- visible: false,
- loading: false,
- rules,
- params: {
- sysMaterialApply: sysMaterialApply,
- sysMaterialMedcineApply: sysMaterialMedcineApply,
- sysMaterialMedcineItemApply: [],
- applyBillInfo: applyBillInfo,
- },
-
- maintenanceMaterialType: {
- drugName: "",
- drugCode: "",
- drugId: "",
- },
-
- materialReference: materialReference,
- materialColums: MaterialColums[0],
- tabName: tabName,
- TabColumns: TabColumns,
- count: 0,
- delDemandItemList: [],
- };
- },
- computed: {
- title: {
- get() {
- const { addType } = this;
- if (addType === "add") {
- return "新 增";
- }
- if (addType === "edit") {
- return "编 辑";
- }
- if (addType === "see") {
- return "查 看";
- }
- },
- set() {},
- },
- },
- watch: {
- "params.sysMaterialApply.isMedicine": {
- handler: async function (nVal, oVal) {
- this.params.sysMaterialMedcineApply.isDrug = nVal === "0" ? "2" : "";
- if (nVal === "2") {
-
- try {
- let { code, rows } = await REFER({
- type: "MEDICINE_DRUG",
- search: "其他非医疗器械",
- isPage: false,
- });
- if (code == 200) {
- console.log(rows, "rows");
- let { id, code, name } = rows[0];
- this.params.sysMaterialMedcineItemApply = [
- {
- drugName: name,
- drugCode: code,
- drugId: id,
- },
- ];
- }
- } catch (error) {}
- }
- },
- },
- "params.sysMaterialApply.expiryDateManagerment": {
- handler: function (nVal, oVal) {
- if (nVal === "0") {
- this.rules.expiryUnitId = [
- {
- required: true,
- message: "效期单位",
- trigger: "change",
- },
- ];
- this.rules.usefulLife = [
- {
- required: true,
- message: "有效期",
- trigger: "change",
- },
- ];
- this.rules.usefulLifeUnitId = [
- {
- required: true,
- message: "有效期至单位",
- trigger: "change",
- },
- ];
- this.rules.recentWarningPeriod = [
- {
- required:
- this.params.sysMaterialApply.nearOnsetManagerment === "0",
- message: "近效期预警天数",
- trigger: "change",
- },
- ];
- } else {
- this.rules.expiryUnitId = null;
- this.rules.usefulLife = null;
- this.rules.usefulLifeUnitId = null;
- this.rules.recentWarningPeriod = null;
- this.params.sysMaterialApply.nearOnsetManagerment = "2";
- }
- this.count++;
- },
- },
- "params.sysMaterialApply.nearOnsetManagerment": {
- handler: function (nVal, oVal) {
- if (nVal === "0") {
- this.rules.recentWarningPeriod = [
- {
- required:
- this.params.sysMaterialApply.expiryDateManagerment === "0",
- message: "近效期预警天数",
- trigger: "change",
- },
- ];
- } else {
- this.rules.recentWarningPeriod = null;
- }
- this.count++;
- },
- },
- },
- methods: {
- setVisible(prop) {
- this.visible = prop;
- },
- beforeOpen() {
- let { name, nickName, deptId, deptName, orgId, orgName } =
- this.$store.state.user;
- if (this.addType === "add") {
- this.params.sysMaterialApply.isMedicine = "0";
- this.params.sysMaterialApply.storageCondition = "MED2001";
- this.params.sysMaterialApply.isInventoryStatus = "0";
- this.params.sysMaterialApply.transportationCondition = "MED3003";
- this.params.sysMaterialApply.isEnable = "0";
- this.params.sysMaterialApply.materialRateName = "专票13%";
- this.params.sysMaterialApply.materialRate = "1001A11000000000TPTF";
- this.params.sysMaterialApply.proposerId = name;
- this.params.sysMaterialApply.proposerName = nickName;
- this.params.sysMaterialApply.orgId = "";
- this.params.sysMaterialApply.orgName = "德荣集团";
- this.params.sysMaterialApply.expiryDateManagerment = "0";
- this.params.sysMaterialApply.nearOnsetManagerment = "0";
-
- this.params.sysMaterialMedcineApply.dosageFrom = "0001A11000000000BX7Z";
- this.params.sysMaterialMedcineApply.dosageFromName = "其他";
- }
- if (this.addType === "see") {
- this.TabColumns = this.TabColumns.map((tab) => {
- return {
- ...tab,
- TableColumns: tab.TableColumns.map(({ item, attr }) => {
- return {
- item: { ...item },
- attr: {
- ...attr,
- disabled: true,
- },
- };
- }),
- };
- });
- }
- },
-
- async fetchItem(prop) {
- console.log(prop, "prop----------------");
- try {
-
- this.loading = true;
- let { code, data } = await getReqDetail(prop.id);
- if (code == 200) {
- this.params = data;
-
- if (this.addType === "add") {
- this.copyEmpty();
- }
- }
- } catch (err) {
-
- console.error(err);
- } finally {
-
- this.loading = false;
- }
- },
-
- copyEmpty() {
- const { id, name, nickName } = this.$store.state.user;
- let {
- sysMaterialApply,
- sysMaterialMedcineApply,
- sysMaterialMedcineItemApply,
- } = this.params;
-
- sysMaterialApply["id"] = "";
- sysMaterialApply["code"] = "";
- sysMaterialApply["billCode"] = "";
- sysMaterialApply["diCode"] = "";
- sysMaterialApply["healthCode"] = "";
- sysMaterialApply["proposerName"] = nickName;
- sysMaterialApply["proposerId"] = name;
-
- sysMaterialMedcineApply["id"] = "";
-
- sysMaterialMedcineItemApply.length &&
- (this.params.sysMaterialMedcineItemApply =
- sysMaterialMedcineItemApply.map((item) => {
- return {
- ...item,
- id: "",
- };
- }));
-
- this.params.applyBillInfo = {
- ...this.$init.params([
- ...this.TabColumns.find(({ item }) => item.key === "applyBillInfo")
- .TableColumns,
- ]),
- auditTime: "",
- };
- },
-
- async hide() {
- const {
- TabColumns,
- TabColumns: [
- {
- item: { key: tabName },
- },
- ],
- } = useColumns();
- this.visible = false;
- this.$emit("success");
- this.tabName = tabName;
- this.TabColumns = TabColumns;
- this.params = {
- sysMaterialApply: this.$init.params([
- ...TabColumns.find(({ item }) => item.key === "sysMaterialApply")
- .TableColumns,
- ]),
- sysMaterialMedcineApply: this.$init.params([
- ...TabColumns.find(
- ({ item }) => item.key === "sysMaterialMedcineApply"
- ).TableColumns,
- ]),
- sysMaterialMedcineItemApply: [],
- applyBillInfo: this.$init.params([
- ...TabColumns.find(({ item }) => item.key === "applyBillInfo")
- .TableColumns,
- ]),
- };
- },
-
- async useRowAdd(prop) {
- let { open } = this.$refs.materialTypeTree[0];
- open();
-
-
-
-
-
-
-
- },
-
- async useRowRemove(prop, scope) {
- scope.row.delFlag = "2";
- let delList = [];
- delList = this.params[prop].filter((item) => {
- return item.delFlag == "2";
- });
- this.params[prop] = this.params[prop].filter((item) => {
- return item.delFlag == "0";
- });
- this.delDemandItemList.push(...delList);
- },
-
- handleParams() {
- let list = [];
- let {
- sysMaterialApply: { isMedicine },
- sysMaterialMedcineItemApply,
- } = this.params;
- list.push(...sysMaterialMedcineItemApply, ...this.delDemandItemList);
-
- let param = JSON.parse(JSON.stringify(this.params));
- param.sysMaterialMedcineItemApply = list;
- if (isMedicine === "0" && !sysMaterialMedcineItemApply.length) {
- return this.$modal.notifyWarning("医药物料需要维护物料类别!");
- }
- console.log(param, "param最终保存传输的值");
- return param;
- },
-
- async useSave() {
- try {
- this.loading = true;
- let params = await this.handleParams();
- if (params) {
- let { code, msg } =
- this.addType === "add"
- ? await addReq(params)
- : await editReq(params);
- code == 200 && this.hide();
- this.$notify({
- type: code == 200 ? "success" : "error",
- message: msg,
- });
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- },
-
- async useSubmit() {
- try {
- this.loading = true;
- let params = await this.handleParams();
- if (params) {
- let { code, msg } = await betchSubmit({ ids: [Number(params.id)] });
- code == 200 && this.hide();
- this.$notify({
- type: code == 200 ? "success" : "error",
- message: msg,
- });
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- },
-
- async saveSubmit() {
- try {
- this.loading = true;
- let params = await this.handleParams();
- if (params) {
- let { code, msg } = await saveAndToOa(params);
- code == 200 && this.hide();
- this.$notify({
- type: code == 200 ? "success" : "error",
- message: msg,
- });
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- },
- materialTypeChange(tabName) {
- let { drugId } = this.maintenanceMaterialType;
- let isExist = this.params[tabName].find((item) => item.drugId === drugId);
- if (isExist) {
- this.$message.warning({
- message: "请勿重复选择",
- });
- } else {
- this.params[tabName].push({
- ...this.maintenanceMaterialType,
- delFlag: "0",
- });
- }
- },
-
- openMaterialReference() {
- let { open } = this.$refs.materialPopoverSelect[0];
- open();
- },
- materialReferenceChange(prop, { source }) {
- console.log(prop, "prop");
- console.log(source, "source");
- this.params.sysMaterialApply = {
- ...this.params.sysMaterialApply,
- ...source,
- };
- },
- },
- created() {},
- mounted() {},
- destroyed() {},
- };
- </script>
- <template>
- <el-drawer
- class="detailsRequsition"
- v-bind="$attrs"
- v-on="$listeners"
- v-loading="loading"
- :visible.sync="visible"
- :size="width"
- :show-close="false"
- destroy-on-close
- @close="hide"
- @open="beforeOpen"
- >
- <div
- slot="title"
- style="display: flex; justify-content: space-between; align-items: center"
- >
- <h3>{{ title }}</h3>
- <div>
- <el-button
- v-if="addType !== 'see'"
- type="primary"
- :size="$attrs.size"
- :loading="loading"
- @click="useSave"
- >保 存</el-button
- >
- <el-button
- v-if="
- addType !== 'see' &&
- (params.sysMaterialApply.status == '0' ||
- params.sysMaterialApply.status == '3')
- "
- type="primary"
- :size="$attrs.size"
- :loading="loading"
- @click="saveSubmit"
- >保存并提交</el-button
- >
- <el-button
- v-if="
- addType === 'see' &&
- (params.sysMaterialApply.status == '0' ||
- params.sysMaterialApply.status == '3')
- "
- type="primary"
- :size="$attrs.size"
- :loading="loading"
- @click="useSubmit"
- >提交</el-button
- >
- <el-button :size="$attrs.size" :loading="loading" @click="hide"
- >取 消</el-button
- >
- </div>
- </div>
- <el-tabs
- v-model="tabName"
- style="margin: 0 16px"
- type="border-card"
- :key="count"
- >
- <el-tab-pane
- v-for="(
- { item, TableColumns: columns, attr: { is } }, index
- ) in TabColumns"
- :key="index"
- :label="item.title"
- :name="item.key"
- lazy
- >
-
- <component
- v-if="is === 'el-super-form' && visible"
- :is="is"
- v-model="params[item.key]"
- :dict="dict"
- :rules="rules"
- :size="$attrs.size"
- :columns="columns"
- :ref="tabName"
- label-width="166px"
- label-position="right"
- style="padding: 0px 18px"
- >
-
- <template slot="name" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="addType === 'see'"
- style="width: 100%"
- >
- <el-button
- slot="append"
- icon="el-icon-search"
- @click="openMaterialReference"
- >
- <el-popover-select-v2
- ref="materialPopoverSelect"
- v-show="false"
- title="物料"
- v-model="materialReference.name"
- :source.sync="materialReference"
- v-bind="materialColums.attr"
- style="width: 100%"
- @change="materialReferenceChange"
- >
- </el-popover-select-v2>
- </el-button>
- </component>
- </template>
-
- <template slot="isDrug" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="
- params.sysMaterialApply.isMedicine !== '0' || addType === 'see'
- "
- >
-
- <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="
- params.sysMaterialApply.expiryDateManagerment !== '0' ||
- addType === 'see'
- "
- style="width: 100%"
- ></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="
- params.sysMaterialApply.expiryDateManagerment !== '0' ||
- addType === 'see'
- "
- >
- <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="
- params.sysMaterialApply.expiryDateManagerment !== '0' ||
- addType === 'see'
- "
- >
- <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="
- params.sysMaterialApply.expiryDateManagerment !== '0' ||
- addType === 'see'
- "
- style="width: 100%"
- ></component>
- </template>
-
- <template slot="manufacturerName" slot-scope="scope">
- <component
- v-bind="scope.attr"
- v-model="scope.row[scope.item.key]"
- copy
- readonly
- :size="$attrs.size"
- :source.sync="scope.row"
- :disabled="addType === 'see'"
- style="width: 100%"
- ></component>
- </template>
- </component>
-
- <component
- v-if="is === 'el-super-ux-table'"
- :is="is"
- v-model="params[item.key]"
- :dict="dict"
- :height="420"
- :ref="tabName"
- :columns="columns"
- :size="$attrs.size"
- >
- <ux-table-column
- fixed="right"
- title="操作"
- width="120"
- align="center"
- >
- <template slot="header" slot-scope="scope">
- <el-button
- v-if="tabName === 'sysMaterialMedcineItemApply'"
- type="text"
- :size="$attrs.size"
- :disabled="addType === 'see'"
- @click="useRowAdd(tabName)"
- >
- 增行
- <el-popover-tree-select
- ref="materialTypeTree"
- v-show="false"
- v-model="maintenanceMaterialType.drugName"
- :source.sync="maintenanceMaterialType"
- referName="MEDICINE_DRUG"
- valueKey="name"
- :dataMapping="{
- drugCode: 'code',
- drugId: 'id',
- }"
- :defaultProps="{
- label: function (data, node) {
- return data.code + '' + data.name;
- },
- children: 'children',
- }"
- @change="materialTypeChange(tabName)"
- ></el-popover-tree-select>
- </el-button>
- </template>
- <template slot-scope="scope">
- <el-button
- type="text"
- :size="$attrs.size"
- :disabled="addType === 'see'"
- @click.native.prevent="useRowRemove(tabName, scope)"
- >
- 删除
- </el-button>
-
- </template>
- </ux-table-column>
- </component>
- </el-tab-pane>
- </el-tabs>
- </el-drawer>
- </template>
- <style scoped lang="scss">
- ::v-deep.detailsRequsition .el-drawer__header {
- margin: 0;
- padding: 0 16px;
- }
- </style>
|