Ver código fonte

Merge branch 'master' of http://120.46.159.163:7400/ezhizao/ezhizao_dms_vue

guoyujia 1 ano atrás
pai
commit
9413aa5dff
1 arquivos alterados com 129 adições e 255 exclusões
  1. 129 255
      src/views/business/carrier/index.vue

+ 129 - 255
src/views/business/carrier/index.vue

@@ -3,24 +3,11 @@
     <!-- 左侧区域 -->
     <section class="list-part-container">
       <!-- 搜索区域 -->
-      <el-form
-        class="list-search-container"
-        :model="queryParams"
-        ref="queryRef"
-        :inline="true"
-      >
+      <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
         <el-form-item class="section-title" label="载具类别" />
         <el-form-item>
-          <el-button type="success" icon="Refresh" @click="handleQueryCategory"
-            >刷新</el-button
-          >
-          <el-button
-            type="primary"
-            icon="Plus"
-            @click="handleShowCategoryDialog(null)"
-            v-hasPermi="['business:carrier:add']"
-            >新增</el-button
-          >
+          <el-button type="success" icon="Refresh" @click="handleQueryCategory">刷新</el-button>
+          <el-button type="primary" icon="Plus" @click="handleShowCategoryDialog(null)" v-hasPermi="['business:carrier:add']">新增</el-button>
         </el-form-item>
       </el-form>
       <!-- 列表区 -->
@@ -40,46 +27,21 @@
               </template>
             </el-table-column>
           </el-table> -->
-          <el-tree 
-            ref="categoryTable"
-            v-loading="categoryLoading"
-            :data="carrierCategoryList"
-            :props="{ label: 'name', children: 'children' }"
-            :expand-on-click-node="false"
-            :filter-node-method="filterNode"
-            default-expand-all
-            node-key="id"
-            highlight-current
-            @node-click="handleCurrentCategoryChange"
-          >
+          <el-tree ref="categoryTable" v-loading="categoryLoading" :data="carrierCategoryList" :props="{ label: 'name', children: 'children' }" :expand-on-click-node="false" :filter-node-method="filterNode" default-expand-all node-key="id" highlight-current @node-click="handleCurrentCategoryChange">
             <template #default="{ node, data }">
-              <div
-                style="
+              <div style="
                   display: flex;
                   width: 100%;
                   justify-content: space-between;
-                "
-              >
-              <span>
-                <span v-if="data.parentId == 0" style="display: inline-block; width: 20px;">{{ getNodeIndex(data) }}. </span>
-                <span>{{ node.label }}</span>
+                ">
+                <span>
+                  <span v-if="data.parentId == 0" style="display: inline-block; width: 20px;">{{ getNodeIndex(data) }}. </span>
+                  <span>{{ node.label }}</span>
                 </span>
                 <span>
-                  <el-button
-                    link
-                    type="warning"
-                    icon="Edit"
-                    @click="handleShowCategoryDialog(data)"
-                    v-hasPermi="['business:carrier:edit']"
-                    >编辑
+                  <el-button link type="warning" icon="Edit" @click="handleShowCategoryDialog(data)" v-hasPermi="['business:carrier:edit']">编辑
                   </el-button>
-                  <el-button
-                    link
-                    type="danger"
-                    icon="Delete"
-                    @click="handleDeleteCategory(data)"
-                    v-hasPermi="['business:carrier:remove']"
-                    >删除
+                  <el-button link type="danger" icon="Delete" @click="handleDeleteCategory(data)" v-hasPermi="['business:carrier:remove']">删除
                   </el-button>
                 </span>
               </div>
@@ -91,89 +53,33 @@
 
     <!-- 右侧区域 -->
     <section class="list-part-container" style="flex: 2">
-      <el-form
-        class="list-search-container"
-        :model="carrierParams"
-        ref="queryRef"
-        :inline="true"
-      >
+      <el-form class="list-search-container" :model="carrierParams" ref="queryRef" :inline="true">
         <el-form-item class="section-title" label="载具管理" />
         <el-form-item label="载具编号:">
-          <el-input
-            placeholder="请输入载具编号"
-            clearable
-            style="width: 180px"
-            v-model.trim="carrierParams.code"
-            @keydown.enter.prevent
-            @keyup.enter="handleQueryCarrier"
-          />
+          <el-input placeholder="请输入载具编号" clearable style="width: 180px" v-model.trim="carrierParams.code" @keydown.enter.prevent @keyup.enter="handleQueryCarrier" />
         </el-form-item>
         <el-form-item>
-          <el-button type="info" icon="Search" @click="handleQueryCarrier"
-            >搜索</el-button
-          >
-          <el-button type="success" icon="Refresh" @click="handleRefreshCarrier"
-            >刷新</el-button
-          >
+          <el-button type="info" icon="Search" @click="handleQueryCarrier">搜索</el-button>
+          <el-button type="success" icon="Refresh" @click="handleRefreshCarrier">刷新</el-button>
           <!-- <el-button type="primary" icon="Plus" @click="handleShowCarrierDialog(null)" v-hasPermi="['business:carrier:add']">新增</el-button> -->
-          <el-button
-            :disabled="selections.length == 0"
-            type="warning"
-            icon="Download"
-            @click="handleBatchDownloadQrCode"
-            >批量下载二维码</el-button
-          >
+          <el-button :disabled="selections.length == 0" type="warning" icon="Download" @click="handleBatchDownloadQrCode">批量下载二维码</el-button>
         </el-form-item>
       </el-form>
 
       <!-- 列表区 -->
       <div class="el-table-container">
         <div class="el-table-inner-container">
-          <el-table
-            v-loading="carrierLoading"
-            row-key="id"
-            @selection-change="handleSelectionChange"
-            :data="carrierList"
-            height="100%"
-          >
-            <el-table-column
-              type="selection"
-              width="40"
-              align="center"
-              :reserve-selection="true"
-            />
-            <el-table-column
-              type="index"
-              label="行号"
-              width="50"
-              align="center"
-            />
-            <el-table-column
-              prop="code"
-              label="载具编号"
-              width="80"
-              align="center"
-            />
-            <el-table-column
-              label="状态"
-              width="70"
-              prop="isAbandoned"
-              align="center"
-            >
+          <el-table v-loading="carrierLoading" row-key="id" @selection-change="handleSelectionChange" :data="carrierList" height="100%">
+            <el-table-column type="selection" width="40" align="center" :reserve-selection="true" />
+            <el-table-column type="index" label="行号" width="50" align="center" />
+            <el-table-column prop="code" label="载具编号" width="80" align="center" />
+            <el-table-column label="状态" width="70" prop="isAbandoned" align="center">
               <template #default="scope">
                 {{ scope.row.status }}
-                <dict-tag
-                  :options="carrier_status"
-                  :value="scope.row.isAbandoned"
-                />
+                <dict-tag :options="carrier_status" :value="scope.row.isAbandoned" />
               </template>
             </el-table-column>
-            <el-table-column
-              prop="createTime"
-              label="添加日期"
-              width="120"
-              align="center"
-            >
+            <el-table-column prop="createTime" label="添加日期" width="120" align="center">
               <template #default="scope">
                 {{ proxy.moment(scope.row.createTime).format("YYYY-MM-DD") }}
               </template>
@@ -198,24 +104,8 @@
                 <!-- <el-button link type="warning" icon="Edit" @click="handleShowCarrierDialog(scope.row.id)" v-hasPermi="['business:carrier:edit']">
                   编辑
                 </el-button> -->
-                <el-button
-                  v-if="scope.row.isAbandoned === 0"
-                  link
-                  type="danger"
-                  icon="Delete"
-                  @click="handleShowAbandonDialog(scope.row.id)"
-                  v-hasPermi="['business:carrier:abandonment']"
-                  >废弃</el-button
-                >
-                <el-button
-                  v-else
-                  link
-                  type="success"
-                  icon="CircleCheck"
-                  @click="handleUnAbandoned(scope.row)"
-                  v-hasPermi="['business:carrier:unAbandonment']"
-                  >取消废弃</el-button
-                >
+                <el-button v-if="scope.row.isAbandoned === 0" link type="danger" icon="Delete" @click="handleShowAbandonDialog(scope.row.id)" v-hasPermi="['business:carrier:abandonment']">废弃</el-button>
+                <el-button v-else link type="success" icon="CircleCheck" @click="handleUnAbandoned(scope.row)" v-hasPermi="['business:carrier:unAbandonment']">取消废弃</el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -223,204 +113,189 @@
       </div>
 
       <!-- 分页 -->
-      <pagination
-        v-show="carrierTotal > 0"
-        :total="carrierTotal"
-        v-model:page="carrierParams.pageNum"
-        v-model:limit="carrierParams.pageSize"
-        @pagination="getCarriers"
-      />
+      <pagination v-show="carrierTotal > 0" :total="carrierTotal" v-model:page="carrierParams.pageNum" v-model:limit="carrierParams.pageSize" @pagination="getCarriers" />
     </section>
 
     <!-- 载具类别表单 -->
-    <carrier-category-form
-      ref="carrierCategoryRef"
-      @handleSaveSuccess="handleQueryCategory"
-    />
+    <carrier-category-form ref="carrierCategoryRef" @handleSaveSuccess="handleQueryCategory" />
 
     <!-- 载具表单 -->
     <carrier-form ref="carrierRef" @handleSaveSuccess="handleRefreshCarrier" />
 
     <!-- 废弃弹窗 -->
-    <carrier-abandonment-form
-      ref="carrierAbandonmentRef"
-      @handleSaveSuccess="handleRefreshCarrier"
-    />
+    <carrier-abandonment-form ref="carrierAbandonmentRef" @handleSaveSuccess="handleRefreshCarrier" />
   </div>
 </template>
 
 <script setup name="Process">
-import {
-  listCategory,
-  delCategory,
-  listCarrier,
-  saveCarrierReject,
-  download,
-} from "@/api/business/carrier";
-import carrierForm from "./form";
-import carrierCategoryForm from "./formCategory";
-import carrierAbandonmentForm from "./formAbandonment";
-import { nextTick } from "vue";
-const { proxy } = getCurrentInstance();
-const { carrier_status } = proxy.useDict("carrier_status");
-const webHost = import.meta.env.VITE_APP_PRODUCTION_API;
-const categoryTable = ref(null);
-const carrierCategoryList = ref([]);
-const carrierList = ref([]);
-const currentCategory = ref({});
-const defaultCheckedKey = ref('');
-const categoryLoading = ref(false);
-const carrierLoading = ref(false);
-const carrierTotal = ref(0);
-const selections = ref([]);
+import { listCategory, delCategory, listCarrier, saveCarrierReject, download } from '@/api/business/carrier'
+import carrierForm from './form'
+import carrierCategoryForm from './formCategory'
+import carrierAbandonmentForm from './formAbandonment'
+import { nextTick } from 'vue'
+const { proxy } = getCurrentInstance()
+const { carrier_status } = proxy.useDict('carrier_status')
+const webHost = import.meta.env.VITE_APP_PRODUCTION_API
+const categoryTable = ref(null)
+const carrierCategoryList = ref([])
+const carrierList = ref([])
+const currentCategory = ref({})
+const defaultCheckedKey = ref('')
+const categoryLoading = ref(false)
+const carrierLoading = ref(false)
+const carrierTotal = ref(0)
+const selections = ref([])
 const data = reactive({
   form: {},
   queryParams: {
-    code: "",
+    code: '',
     pageNum: 1,
-    pageSize: 10,
+    pageSize: 10
   },
   carrierParams: {
-    code: "",
+    code: '',
     pageNum: 1,
-    pageSize: 10,
-  },
-});
+    pageSize: 10
+  }
+})
 
-const { queryParams, carrierParams } = toRefs(data);
+const { queryParams, carrierParams } = toRefs(data)
 /** 查询对象 */
 
 /****************************  载具类别相关事件  ****************************/
 /** 载具分类列表 */
 const getCategories = () => {
-  categoryLoading.value = true;
+  categoryLoading.value = true
   listCategory().then((res) => {
-    categoryLoading.value = false;
-    carrierCategoryList.value = res.rows;
+    categoryLoading.value = false
+    carrierCategoryList.value = res.rows
     if (carrierCategoryList.value.length > 0) {
-      currentCategory.value = carrierCategoryList.value[0];
-    nextTick(() => {
-      proxy.$refs.categoryTable.setCurrentKey(currentCategory.value.id)
-      handleCurrentCategoryChange(currentCategory.value)
-    })
+      currentCategory.value = carrierCategoryList.value[0]
+      nextTick(() => {
+        proxy.$refs.categoryTable.setCurrentKey(currentCategory.value.id)
+        handleCurrentCategoryChange(currentCategory.value)
+      })
       // categoryTable.value.setCurrentRow(currentCategory.value);
     }
-  });
-};
-
+  })
+}
+const filterNode = (value, data) => {
+  queryParams.value.code = ''
+  if (!value) {
+    return true
+  }
+  return data.name.indexOf(value) !== -1
+}
 const handleCurrentCategoryChange = (row) => {
   if (row) {
-    currentCategory.value = row;
+    currentCategory.value = row
   } else {
-    currentCategory.value = {};
+    currentCategory.value = {}
     if (carrierCategoryList.value.length > 0) {
-      currentCategory.value = carrierCategoryList.value[0];
+      currentCategory.value = carrierCategoryList.value[0]
     }
   }
   if (currentCategory.value.id) {
     //categoryTable.value.setCurrentRow(currentCategory.value);
-    getCarriers();
+    getCarriers()
   } else {
-    carrierList.value = [];
-    carrierTotal.value = 0;
+    carrierList.value = []
+    carrierTotal.value = 0
   }
-};
+}
 function getNodeIndex(data) {
-  const index = carrierCategoryList.value.findIndex(
-    (item) => item.id === data.id
-  );
-  return index + 1;
+  const index = carrierCategoryList.value.findIndex((item) => item.id === data.id)
+  return index + 1
 }
 function handleShowCategoryDialog(data) {
-  if(data) {
-     proxy.$refs.carrierCategoryRef.open(data.id);
-  }
-  else {
-    proxy.$refs.carrierCategoryRef.open();
-  }
+  if (data) {
+    proxy.$refs.carrierCategoryRef.open(data.id)
+  } else {
+    proxy.$refs.carrierCategoryRef.open()
   }
+}
 
 /** 删除按钮操作 */
 const handleDeleteCategory = (data) => {
   proxy.$modal
-    .confirm("确定删除选中项?")
+    .confirm('确定删除选中项?')
     .then(() => {
-      return delCategory(data.id);
+      return delCategory(data.id)
     })
     .then(() => {
-      proxy.$modal.msgSuccess("操作成功!");
-      getCategories();
+      proxy.$modal.msgSuccess('操作成功!')
+      getCategories()
     })
-    .catch(() => {});
-};
+    .catch(() => {})
+}
 
 const handleQueryCategory = () => {
-  getCategories();
-};
+  getCategories()
+}
 /****************************  载具相关事件  ****************************/
 
 const getCarriers = () => {
-  carrierLoading.value = true;
-  carrierParams.value.categoryId = currentCategory.value.id;
+  carrierLoading.value = true
+  carrierParams.value.categoryId = currentCategory.value.id
   listCarrier(carrierParams.value).then((res) => {
-    carrierLoading.value = false;
-    carrierList.value = res.rows;
-    carrierTotal.value = res.total;
-  });
-};
+    carrierLoading.value = false
+    carrierList.value = res.rows
+    carrierTotal.value = res.total
+  })
+}
 /**
  * 列表checkbox列选择 事件
  */
 function handleSelectionChange(selection) {
-  selections.value = selection;
-  console.log(selections.value);
+  selections.value = selection
+  console.log(selections.value)
 }
 const handleRefreshCarrier = () => {
-  getCarriers();
-};
+  getCarriers()
+}
 
 const handleQueryCarrier = () => {
-  carrierParams.value.pageNum = 1;
-  handleRefreshCarrier();
-};
+  carrierParams.value.pageNum = 1
+  handleRefreshCarrier()
+}
 
 /** 修改按钮操作 */
 const handleShowCarrierDialog = (id) => {
-  proxy.$refs.carrierRef.open({ categoryId: currentCategory.value.id, id: id });
-};
+  proxy.$refs.carrierRef.open({ categoryId: currentCategory.value.id, id: id })
+}
 
 const handleShowAbandonDialog = (id) => {
-  proxy.$refs.carrierAbandonmentRef.open({ id: id });
-};
+  proxy.$refs.carrierAbandonmentRef.open({ id: id })
+}
 
 const handleUnAbandoned = (row) => {
   proxy.$modal
-    .confirm("确定取消废弃选中项?")
+    .confirm('确定取消废弃选中项?')
     .then(() => {
-      var carrierReject = {};
-      carrierReject.carrierId = row.id;
-      carrierReject.isAbandoned = 0;
-      carrierReject.operaionDate = proxy.moment().format("YYYY-MM-DD");
-      return saveCarrierReject(carrierReject);
+      var carrierReject = {}
+      carrierReject.carrierId = row.id
+      carrierReject.isAbandoned = 0
+      carrierReject.operaionDate = proxy.moment().format('YYYY-MM-DD')
+      return saveCarrierReject(carrierReject)
     })
     .then(() => {
-      proxy.$modal.msgSuccess("操作成功!");
-      handleRefreshCarrier();
+      proxy.$modal.msgSuccess('操作成功!')
+      handleRefreshCarrier()
     })
-    .catch(() => {});
-};
+    .catch(() => {})
+}
 
 /** 批量下载二维码 */
 function handleBatchDownloadQrCode() {
+  console.log(selections.value)
   for (var i = 0; i < selections.value.length; i++) {
-    // window.open(webHost + selections.value[i].qcCode)
-    console.log(webHost + selections.value[i].qcCode);
+    console.log(webHost + selections.value[i].qcCode)
 
-    var link = document.createElement("a");
-    link.href = webHost + selections.value[i].qcCode;
-    link.download = selections.value[i].code; // 可以根据需要设置下载的文件名
-    link.target = "_blank"; // 可以根据需要选择是否在新窗口中下载
-    link.click();
+    var link = document.createElement('a')
+    link.href = webHost + selections.value[i].qcCode
+    link.download = selections.value[i].code // 可以根据需要设置下载的文件名
+    link.target = '_blank' // 可以根据需要选择是否在新窗口中下载
+    link.click()
   }
   // download({}).then((res) => {
   //   if (res.code === 200) {
@@ -429,14 +304,14 @@ function handleBatchDownloadQrCode() {
   // })
 }
 onMounted(() => {
-  getCategories();
-});
+  getCategories()
+})
 </script>
 <style scoped>
 :deep(.el-tree-node__label) {
   font-size: 14px !important;
   display: inline-block;
-    width: 100%;
+  width: 100%;
 }
 :deep(.el-tree-node__content) {
   height: 40px;
@@ -444,5 +319,4 @@ onMounted(() => {
   padding: 8px 0;
   line-height: 23px;
 }
-
 </style>