فهرست منبع

fix:销售反馈新增备注

luoxiao 6 روز پیش
والد
کامیت
f7bd168227
2فایلهای تغییر یافته به همراه167 افزوده شده و 1 حذف شده
  1. 8 0
      src/api/sales/index.ts
  2. 159 1
      src/views/sales/index.vue

+ 8 - 0
src/api/sales/index.ts

@@ -63,3 +63,11 @@ export function dealFeedback(data: object) {
     data,
   });
 }
+
+export function updateSalesData(data: object) {
+  return request({
+    url: "/api/v1/sales/update",
+    method: "post",
+    data,
+  });
+}

+ 159 - 1
src/views/sales/index.vue

@@ -69,6 +69,13 @@
             <el-button link @click="toDetail(row)" type="primary"
               >详情</el-button
             >
+            <el-button
+              link
+              v-if="row.state === 3"
+              @click="handleRemark(row)"
+              type="primary"
+              >备注</el-button
+            >
           </template>
         </el-table-column>
       </el-table>
@@ -90,13 +97,66 @@
       <Handle6 ref="handle6Ref" @finish="getData"></Handle6>
       <Handle7 ref="handle7Ref" @finish="getData"></Handle7>
     </div>
+    <el-dialog
+      v-model="dialogVisible"
+      :title="`备注 (${currentRow.materialModel || ''})`"
+      width="40%"
+    >
+      <div class="remark-container">
+        <div
+          v-for="(remark, index) in remarks"
+          :key="index"
+          class="remark-item"
+        >
+          <el-input
+            v-model="remark.content"
+            type="textarea"
+            :rows="3"
+            placeholder="请输入备注内容"
+            @change="updateRemark(index, remark.content)"
+          />
+          <div class="remark-actions">
+            <div>
+              <el-button
+                type="danger"
+                size="small"
+                @click="removeRemark(index)"
+                :icon="Delete"
+                circle
+              />
+            </div>
+            <div class="remark-info">
+              <span class="remark-user">{{ remark.user }}</span>
+              <span class="remark-time">{{ remark.time }}</span>
+            </div>
+          </div>
+        </div>
+        <el-button
+          type="primary"
+          @click="addRemark"
+          class="add-btn"
+          :icon="Plus"
+          >新增备注</el-button
+        >
+      </div>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="dialogVisible = false">取消</el-button>
+          <el-button type="primary" @click="handleRemarkSubmit">保存</el-button>
+        </span>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
 import Search from "@/components/Search/index.vue";
 import { useSpcStore, useUserStore, useDictionaryStore } from "@/store";
-import { deleteFeedback, getSalesData } from "@/api/sales/index";
+import {
+  deleteFeedback,
+  getSalesData,
+  updateSalesData,
+} from "@/api/sales/index";
 import Add from "@/views/sales/add.vue";
 import Detail from "@/views/sales/detail.vue";
 import Handle2 from "@/views/sales/handle2.vue";
@@ -105,6 +165,7 @@ import Handle4 from "@/views/sales/handle4.vue";
 import Handle5 from "@/views/sales/handle5.vue";
 import Handle6 from "@/views/sales/handle6.vue";
 import Handle7 from "@/views/sales/handle7.vue";
+import { Plus, Delete } from "@element-plus/icons-vue";
 
 defineOptions({
   name: "SPCSales",
@@ -178,6 +239,63 @@ const toDelete = async (row) => {
   // }
 };
 
+const dialogVisible = ref(false);
+const currentRow = ref({});
+const remarks = ref([]);
+
+const handleRemark = (row) => {
+  dialogVisible.value = true;
+  currentRow.value = row;
+  // 初始化备注数据
+  try {
+    remarks.value = row.remark8 ? JSON.parse(row.remark8) : [];
+  } catch (e) {
+    remarks.value = [];
+  }
+};
+
+const formatNowTime = () => {
+  const date = new Date();
+  return (
+    date.getFullYear() +
+    "年" +
+    (date.getMonth() + 1) +
+    "月" +
+    date.getDate() +
+    "日"
+  );
+};
+
+const addRemark = () => {
+  remarks.value.push({
+    content: "",
+    time: formatNowTime(),
+    user: userStore.user.username,
+  });
+};
+
+const removeRemark = (index) => {
+  remarks.value.splice(index, 1);
+};
+
+const updateRemark = (index, content) => {
+  remarks.value[index].content = content;
+  remarks.value[index].time = formatNowTime();
+  remarks.value[index].user = userStore.user.username;
+};
+
+const handleRemarkSubmit = async () => {
+  const validRemarks = remarks.value.filter((item) => item.content.trim());
+
+  currentRow.value.remark8 = JSON.stringify(validRemarks);
+
+  await updateSalesData(currentRow.value);
+
+  ElMessage.success("备注保存成功");
+  dialogVisible.value = false;
+  getData();
+};
+
 // 处理相关
 const handle2Ref = ref(null);
 const handle3Ref = ref(null);
@@ -297,4 +415,44 @@ watch(
     background-color: #f5f7fa;
   }
 }
+
+.remark-container {
+  max-height: 60vh;
+  overflow-y: auto;
+  padding: 10px;
+
+  .remark-item {
+    margin-bottom: 15px;
+    border-bottom: 1px dashed #eee;
+    padding-bottom: 10px;
+
+    .remark-actions {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      margin-top: 5px;
+
+      .remark-info {
+        display: flex;
+        flex-direction: column;
+        align-items: flex-end;
+
+        .remark-user {
+          font-size: 12px;
+          color: #409eff;
+          margin-bottom: 2px;
+        }
+
+        .remark-time {
+          font-size: 12px;
+          color: #999;
+        }
+      }
+    }
+  }
+
+  .add-btn {
+    margin-top: 10px;
+  }
+}
 </style>