123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- import { ref, reactive, computed, toRefs } from "vue";
- import { Table } from "@/hooks/interface";
- import { ColumnProps } from "@/components/LjVxeTable/interface";
- import { ALLOW_EDIT_STATE } from "@/config/index";
- import { SaveDept, DeleteDept, AuditDept } from "@/api/modules/saleprice";
- import { ElMessage, ElMessageBox } from "element-plus";
- interface defaultState {
- /**
- * @description 单据当前状态
- */
- orderStatus: string;
- /**
- * @description 列表Ref
- */
- VxeTableRef: any;
- /**
- * @description 详情页Ref
- */
- LjDetailRef: any;
- }
- const state = reactive<defaultState>({
- orderStatus: "",
- VxeTableRef: null,
- LjDetailRef: null
- });
- /**
- * @description 表格多选数据操作
- * @param {String} rowKey 当表格可以多选时,所指定的 id
- * */
- export const useHooks = (t?: any) => {
- // 表格配置项
- const columns: ColumnProps<any>[] = [
- { type: "checkbox", width: 80, fixed: "left" },
- {
- field: "deptname",
- title: "部门名称",
- basicinfo: {
- el: "input",
- span: 2,
- editable: ALLOW_EDIT_STATE,
- rules: [{ required: true }]
- }
- },
- {
- field: "pricelistid",
- title: "价格表",
- basicinfo: {
- el: "select",
- span: 2,
- editable: ALLOW_EDIT_STATE,
- rules: [{ required: true }],
- defaultValue: 0
- }
- },
- {
- field: "springtypeid",
- title: "弹簧分类",
- basicinfo: {
- el: "select",
- span: 1,
- editable: ALLOW_EDIT_STATE,
- defaultValue: 0,
- rules: [{ required: true }]
- }
- },
- {
- field: "moneyrate",
- title: "汇率",
- basicinfo: {
- el: "input",
- span: 1,
- editable: ALLOW_EDIT_STATE,
- props: {
- placeholder: "请输入汇率"
- },
- rules: [{ required: true, pattern: new RegExp(/^\d+(\.\d+)?$/), message: "汇率不能为0", trigger: "change" }]
- }
- },
- {
- field: "profitrate",
- title: "利润率",
- basicinfo: {
- el: "input",
- span: 1,
- editable: ALLOW_EDIT_STATE,
- props: {
- placeholder: "请输入利润率"
- },
- rules: [{ required: true, pattern: new RegExp(/^\d+(\.\d+)?$/), message: "利润率不能为0", trigger: "change" }]
- }
- },
- {
- field: "discount",
- title: "折扣率",
- basicinfo: {
- el: "input",
- span: 1,
- editable: ALLOW_EDIT_STATE,
- props: {
- placeholder: "请输入折扣率"
- },
- rules: [{ required: true, pattern: new RegExp(/^\d+(\.\d+)?$/), message: "折扣率不能为0", trigger: "change" }]
- }
- },
- {
- field: "if_rate_auto",
- title: "是否自动读取汇率",
- datatype: "checkbox",
- basicinfo: {
- el: "switch",
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "createtime",
- title: "建立时间",
- basicinfo: {
- visible: false
- }
- },
- {
- field: "modemp",
- title: "修改人",
- basicinfo: {
- visible: false
- }
- },
- {
- field: "moddate",
- title: "修改时间",
- basicinfo: {
- visible: false
- }
- },
- {
- field: "auditemp",
- title: "审核人",
- basicinfo: {
- visible: false
- }
- },
- {
- field: "audidate",
- title: "审核时间",
- basicinfo: {
- visible: false
- }
- },
- {
- field: "manage_amt",
- title: "部门管理费",
- basicinfo: {
- el: "input",
- editable: ALLOW_EDIT_STATE,
- span: 1,
- props: {
- placeholder: "请输入部门管理费"
- }
- // rules: [{ trigger: "change" }]
- }
- },
- {
- field: "mtrltype",
- title: "默认物料类别",
- basicinfo: {
- el: "tree-select",
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "managerate",
- title: "管理费用点",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "com_profitrate",
- title: "公司利润率",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "dannum1_rate",
- title: "散单利润浮动",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "dannum2_rate",
- title: "标准利润浮动",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "dannum3_rate",
- title: "大单利润浮动",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "dannum4_rate",
- title: "小单利润浮动",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- },
- {
- field: "taxes_rate",
- title: "非报关产品税金补偿",
- basicinfo: {
- el: "input",
- props: {
- type: "number"
- },
- span: 2,
- editable: ALLOW_EDIT_STATE
- }
- }
- ];
- // 保存
- const fSave = (param: any) => {
- return new Promise((resolve, reject) => {
- ElMessageBox.confirm("是否确定要保存吗?", "询问", {
- confirmButtonText: "是",
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- SaveDept(param).then(() => {
- ElMessage.success("保存成功!");
- state.VxeTableRef?.refresh();
- resolve({});
- });
- })
- .catch(() => {
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- });
- };
- // 删除
- const fDelete = () => {
- const checkDate = state.VxeTableRef?.element.getCheckboxRecords();
- if (checkDate.length === 0) {
- ElMessage.error("请选择要删除的数据!");
- return;
- }
- const delArr = checkDate.map((item: any) => {
- return { deptid: parseInt(item.deptid), deptname: item.deptname };
- });
- ElMessageBox.confirm("是否确定要删除吗?", "询问", {
- confirmButtonText: "是",
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- DeleteDept({ list: delArr }).then(() => {
- ElMessage.success("删除成功!");
- state.VxeTableRef?.refresh();
- });
- })
- .catch(() => {
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- };
- // 审核
- const fAudit = type => {
- let operate = "审核";
- switch (type) {
- case 1:
- operate = "撤审";
- break;
- case 2:
- operate = "反禁用";
- break;
- case 3:
- operate = "禁用";
- break;
- default:
- operate = "审核";
- break;
- }
- const checkDate = state.VxeTableRef?.element.getCheckboxRecords();
- if (checkDate.length === 0) {
- ElMessage.error(`请选择要${operate}的数据!`);
- return;
- }
- const delArr = checkDate.map((item: any) => {
- return { deptid: parseInt(item.deptid) };
- });
- ElMessageBox.confirm(`是否确定要${operate}吗?`, "询问", {
- confirmButtonText: "是",
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- AuditDept({ list: delArr, type }).then(() => {
- ElMessage.success(`${operate}成功!`);
- state.VxeTableRef?.refresh();
- });
- })
- .catch(() => {
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- };
- return {
- ...toRefs(state),
- columns,
- fSave,
- fDelete,
- fAudit
- };
- };
|