Browse Source

修复图片删除没有删掉界面上的元素

sugangqiang 2 years ago
parent
commit
9a6f2e1729

+ 7 - 1
app/common/controller/Api.php

@@ -455,7 +455,7 @@ class Api extends BaseController {
         if (!TalentApi::checkIsEditable($file["mainId"]))
             return json(["msg" => "当前状态不能删除"]);
         if ($this->chkIsFileOwner($file["mainId"], $file["type"])) {
-            if(!empty($file["url"])){
+            if (!empty($file["url"])) {
                 $filepath = "storage/" . $file["url"];
                 if (file_exists($filepath)) {
                     unlink($filepath);
@@ -811,4 +811,10 @@ class Api extends BaseController {
         return json(\app\common\api\IntegralRecordApi::calIntegral($enterpriseId, $cardType, $cardNumber, $itemId, $amount));
     }
 
+    public function imgViewer() {
+        $img = urlencode("/storage/talent_files/20230224/a0036cc3241dccced03837b961264b4b.jpg");
+        $img = urldecode($img);
+        return view("", ["img" => $img]);
+    }
+
 }

+ 4 - 4
public/static/modular/gate/talentInfo/new_talentInfo_info.js

@@ -976,14 +976,14 @@ TalentInfoInfoDlg.upload = function (fileTypeId, fileId, tableIndex, trIndex) {
     $("#uploadForm").submit();
 }
 //删除附件
-TalentInfoInfoDlg.deleteFile = function (id, state) {
+TalentInfoInfoDlg.deleteFile = function (id, obj) {
     if (!TalentInfoInfoDlg.validateIsEdit())
         return;
     var operation = function () {
         var ajax = new $ax(Feng.ctxPath + "/common/api/deleteFile", function (data) {
             if (data.code == 200) {
                 Feng.success(data.msg);
-                $("input[name='uploadFiles[]'][value='" + id + "']").parents("li").remove();
+                $(obj).parents("li").remove();
                 //$("#fileTable").bootstrapTable("refresh", {});
             } else {
                 Feng.error(data.msg);
@@ -1119,7 +1119,7 @@ TalentInfoInfoDlg.validUploadButton = function (type, fileTypeId, fileId, tableI
             return "<button type=\'button\' onclick=\"TalentInfoInfoDlg.checkFile(this," + fileTypeId + "," + fileId + "," + tableIndex + "," + trIndex + ")\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
                     "<i class=\"fa fa-paste\"></i>修改" +
                     "</button>" +
-                    "<button type='button' onclick=\"TalentInfoInfoDlg.deleteFile(" + fileId + ")\" class=\"btn btn-xs btn-danger\">" +
+                    "<button type='button' onclick=\"TalentInfoInfoDlg.deleteFile(" + fileId + ",this)\" class=\"btn btn-xs btn-danger\">" +
                     "<i class=\"fa fa-times\"></i>删除" +
                     "</button>";
         }
@@ -1157,7 +1157,7 @@ TalentInfoInfoDlg.callBack = function (data) {
 <div style="width: 10%;">' + imgStr + '</div>\n\
 <div style="width: 20%;">\n\
 <button type="button" onclick="TalentInfoInfoDlg.checkFile(this,' + data.typeId + ',' + data.id + ',' + tableIndex + ',' + trIndex + ')" style="margin-right: 10px" class="btn btn-xs btn-info"><i class="fa fa-paste"></i>修改</button>\n\
-<button type="button" onclick="TalentInfoInfoDlg.deleteFile(' + data.id + ')" class="btn btn-xs btn-danger"><i class="fa fa-times"></i>删除</button>\n\
+<button type="button" onclick="TalentInfoInfoDlg.deleteFile(' + data.id + ',this)" class="btn btn-xs btn-danger"><i class="fa fa-times"></i>删除</button>\n\
 </div></li></ul>';
             $(".fileTable").eq(tableIndex).find("tr[data-index='" + trIndex + "']").next("tr.detail-view").find(".imgs").append(html);
         }