123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <div class="mainContentBox">
- <avue-crud
- ref="crudRef"
- v-model:search="search"
- v-model="form"
- :data="data"
- :option="option"
- v-model:page="page"
- @row-save="createRow"
- @row-update="updateRow"
- @row-del="deleteRow"
- @search-change="searchChange"
- @search-reset="resetChange"
- @size-change="dataList"
- @current-change="dataList"
- @selection-change="selectionChange"
- >
- <template #menu="{ size, row, index }">
- <el-button
- v-if="row.state === '0' && row.userName === userStore.user.username"
- type="primary"
- link
- size="small"
- @click="test(row, 0)"
- ><i-ep-edit />处理
- </el-button>
- </template>
- </avue-crud>
- <el-dialog
- v-model="dialog1.visible"
- :title="dialog1.title"
- width="950px"
- @close="dialog1.visible = false"
- >
- <choice-item-page enabled="" @materialInfo="materialInfo"/>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { ref, getCurrentInstance } from "vue";
- import { useCrud } from "@/hooks/userCrud";
- import { useCommonStoreHook,useUserStoreHook} from "@/store";
- const { isShowTable, tableType } = toRefs(useCommonStoreHook());
- const userStore = useUserStoreHook();
- const test = (row) => {
- ElMessageBox.confirm("你确定要处理当前消息吗", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- row.state = 1;
- form.value = row
- updateRow(row).then((res)=>{
- dataList()
- });
- });
- };
- // 传入一个url,后面不带/
- const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
- useCrud({
- src: "/api/v1/warningInfo",
- });
- const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } = Methords; //增删改查
- const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
- const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
- const dialog1 = reactive({
- title: "物料选择",
- visible: false,
- });
- const materialInfo = (value) => {
- form.value.code = value.materialCode
- form.value.name = value.materialName
- form.value.unit = value.unitDictValue
- dialog1.visible = false
- }
- const crudRef = ref(null); //crudRef.value 获取avue-crud对象
- // 设置表格列或者其他自定义的option
- option.value = Object.assign(option.value, {
- delBtn: false,
- selection: false,
- editBtn: false,
- viewBtn: false,
- addBtn: false,
- column: [
- {
- label: "物料编码",
- prop: "materialCode",
- width: 150,
- overHidden: true,
- search: true,
- },
- {
- label: "物料名称",
- prop: "materialName",
- search: true,
- width: 150,
- overHidden: true,
- disabled: true,
- },
- {
- label: "物料型号",
- prop: "materialModel",
- search: true,
- width: 150,
- overHidden: true,
- disabled: true,
- rules: [
- {
- required: true,
- message: "物料名称不能为空",
- trigger: "trigger",
- },
- ],
- },
- {
- label: "预警信息",
- prop: "warningInfo",
- },
- {
- label: "处理人",
- prop: "userName",
- search: true,
- display: false
- },
- {
- label: "状态",
- prop: "state",
- type: 'select',
- dicData: [{label: '未处理',value : '0'},{label: '已处理', value : '1'}],
- },
- {
- label: "创建时间",
- prop: "created",
- width: 180,
- display: false
- },
- {
- label: "处理时间",
- prop: "updated",
- width: 180,
- html: true,
- formatter: (val) => {
- if (val.state === "1") {
- return val.updated
- } else {
- return '';
- }
- },
- },
- ],
- });
- onMounted(() => {
- // console.log("crudRef", crudRef)
- dataList();
- });
- </script>
|