You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tmpl 27 kB

4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <!-- 头部导航栏 -->
  2. {{template "base/head" .}}
  3. <style>
  4. .label_after::after{
  5. margin: -.2em 0 0 .2em;
  6. content: '\00a0';
  7. }
  8. .selectcloudbrain .active.item{
  9. color: #0087f5 !important;
  10. border: 1px solid #0087f5;
  11. margin: -1px;
  12. background: #FFF !important;
  13. }
  14. #deletemodel {
  15. width: 100%;
  16. height: 100%;
  17. }
  18. /* 弹窗 */
  19. #mask {
  20. position: fixed;
  21. top: 0px;
  22. left: 0px;
  23. right: 0px;
  24. bottom: 0px;
  25. filter: alpha(opacity=60);
  26. background-color: #777;
  27. z-index: 1000;
  28. display: none;
  29. opacity: 0.8;
  30. -moz-opacity: 0.5;
  31. padding-top: 100px;
  32. color: #000000
  33. }
  34. #loadingPage {
  35. margin: 200px auto;
  36. width: 50px;
  37. height: 40px;
  38. text-align: center;
  39. font-size: 10px;
  40. display: block;
  41. }
  42. #loadingPage>div {
  43. background-color: green;
  44. height: 100%;
  45. width: 6px;
  46. display: inline-block;
  47. -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
  48. animation: sk-stretchdelay 1.2s infinite ease-in-out;
  49. }
  50. #loadingPage .rect2 {
  51. -webkit-animation-delay: -1.1s;
  52. animation-delay: -1.1s;
  53. }
  54. #loadingPage .rect3 {
  55. -webkit-animation-delay: -1.0s;
  56. animation-delay: -1.0s;
  57. }
  58. #loadingPage .rect4 {
  59. -webkit-animation-delay: -0.9s;
  60. animation-delay: -0.9s;
  61. }
  62. #loadingPage .rect5 {
  63. -webkit-animation-delay: -0.8s;
  64. animation-delay: -0.8s;
  65. }
  66. @-webkit-keyframes sk-stretchdelay {
  67. 0%,
  68. 40%,
  69. 100% {
  70. -webkit-transform: scaleY(0.4)
  71. }
  72. 20% {
  73. -webkit-transform: scaleY(1.0)
  74. }
  75. }
  76. @keyframes sk-stretchdelay {
  77. 0%,
  78. 40%,
  79. 100% {
  80. transform: scaleY(0.4);
  81. -webkit-transform: scaleY(0.4);
  82. }
  83. 20% {
  84. transform: scaleY(1.0);
  85. -webkit-transform: scaleY(1.0);
  86. }
  87. }
  88. /* 消息框 */
  89. .alert {
  90. display: none;
  91. position: fixed;
  92. width: 100%;
  93. z-index: 1001;
  94. padding: 15px;
  95. border: 1px solid transparent;
  96. border-radius: 4px;
  97. text-align: center;
  98. font-weight: bold;
  99. }
  100. .alert-success {
  101. color: #3c763d;
  102. background-color: #dff0d8;
  103. border-color: #d6e9c6;
  104. }
  105. .alert-info {
  106. color: #31708f;
  107. background-color: #d9edf7;
  108. border-color: #bce8f1;
  109. }
  110. .alert-warning {
  111. color: #8a6d3b;
  112. background-color: #fcf8e3;
  113. border-color: #faebcc;
  114. }
  115. .alert-danger {
  116. color: #a94442;
  117. background-color: #f2dede;
  118. border-color: #ebccd1;
  119. }
  120. .pusher {
  121. width: calc(100% - 260px);
  122. box-sizing: border-box;
  123. }
  124. /* 弹窗 (background) */
  125. #imageModal {
  126. display: none;
  127. position: fixed;
  128. z-index: 1;
  129. left: 0;
  130. top: 0;
  131. width: 100%;
  132. height: 100%;
  133. overflow: auto;
  134. background-color: rgb(0, 0, 0);
  135. background-color: rgba(0, 0, 0, 0.4);
  136. }
  137. /* 弹窗内容 */
  138. .modal-content {
  139. background-color: #fefefe;
  140. margin: 15% auto;
  141. padding: 20px;
  142. border: 1px solid #888;
  143. width: 30%;
  144. }
  145. /* 关闭按钮 */
  146. .close {
  147. color: #aaa;
  148. float: right;
  149. font-size: 28px;
  150. font-weight: bold;
  151. }
  152. .close:hover,
  153. .close:focus {
  154. color: black;
  155. text-decoration: none;
  156. cursor: pointer;
  157. }
  158. .dis {
  159. margin-bottom: 20px;
  160. }
  161. .disabled {
  162. cursor: pointer;
  163. pointer-events: none;
  164. }
  165. .time-show{
  166. font-size: 10px;
  167. margin-top: 0.4rem;
  168. display: inline-block;
  169. }
  170. </style>
  171. <!-- 弹窗 -->
  172. <div id="mask">
  173. <div id="loadingPage">
  174. <div class="rect1"></div>
  175. <div class="rect2"></div>
  176. <div class="rect3"></div>
  177. <div class="rect4"></div>
  178. <div class="rect5"></div>
  179. </div>
  180. </div>
  181. <!-- 提示框 -->
  182. <div class="alert"></div>
  183. <div class="repository release dataset-list view">
  184. {{template "repo/header" .}}
  185. <!-- 列表容器 -->
  186. <div class="ui container">
  187. <!-- 中间云脑和新建任务按钮 -->
  188. <!-- <div class="ui three column stack able grid">
  189. <div class="column">
  190. <h2>{{.i18n.Tr "repo.cloudbrain1"}}</h2>
  191. </div>
  192. <div class="column">
  193. </div>
  194. <div class="column right aligned">
  195. {{if .Permission.CanWrite $.UnitTypeCloudBrain}}
  196. <a class="ui green button" href="{{.RepoLink}}/cloudbrain/create">{{.i18n.Tr "repo.cloudbrain.new"}}</a> {{end}}
  197. </div>
  198. </div>
  199. <p>使用鹏城云脑计算资源进行调试,云脑1提供CPU / GPU资源,云脑2提供Ascend NPU资源;调试使用的数据集也需要上传到对应的环境。</p>
  200. <div class="ui blue mini menu selectcloudbrain">
  201. <a class="active item" href="{{.RepoLink}}/cloudbrain">{{svg "octicon-server" 16}} CPU / GPU</a>
  202. <a class="item" href="{{.RepoLink}}/modelarts">{{svg "octicon-server" 16}} Ascend NPU</a>
  203. </div> -->
  204. <div class="ui two column stackable grid ">
  205. <div class="column">
  206. <div class="ui blue small menu compact selectcloudbrain">
  207. <a class="active item" href="{{.RepoLink}}/cloudbrain">{{$.i18n.Tr "repo.modelarts.notebook"}}</a>
  208. <a class="item" href="{{.RepoLink}}/modelarts/train-job">{{$.i18n.Tr "repo.modelarts.train_job"}}</a>
  209. </div>
  210. </div>
  211. <div class="column right aligned">
  212. <div class="ui selection dropdown" style="min-width: 10em;min-height:2.6em;border-radius: .28571429rem;margin-right: 1em;padding: .67em 3.2em .7em 1em;">
  213. {{svg "octicon-server" 16}}
  214. <div class="default text" style="color: rgba(0,0,0,.87);"> CPU / GPU</div>
  215. <i class="dropdown icon"></i>
  216. <div class="menu">
  217. <a class="item" href="{{.RepoLink}}/cloudbrain" data-value="11">CPU / GPU</a>
  218. <a class="item" href="{{.RepoLink}}/modelarts/notebook" data-value="22">Ascend NPU</a>
  219. </div>
  220. </div>
  221. {{if .Permission.CanWrite $.UnitTypeCloudBrain}}
  222. <a class="ui green button" href="{{.RepoLink}}/cloudbrain/create">{{$.i18n.Tr "repo.modelarts.train_job.new_debug"}}</a>{{end}}
  223. </div>
  224. </div>
  225. <!-- 中下列表展示区 -->
  226. <div class="ui grid">
  227. <div class="row">
  228. <div class="ui sixteen wide column">
  229. <!-- 排序区 -->
  230. <!-- <div class="ui sixteen wide column">
  231. <div class="ui two column stackable grid">
  232. <div class="column">
  233. </div>
  234. <div class="column right aligned">
  235. <div class="ui right dropdown type jump item">
  236. <span class="text">
  237. {{.i18n.Tr "repo.issues.filter_sort"}}<i class="dropdown icon"></i>
  238. </span>
  239. </div>
  240. </div>
  241. </div>
  242. </div> -->
  243. <!-- 任务展示 -->
  244. <!-- 表头 -->
  245. <div class="dataset list">
  246. <div class="ui grid stackable" style="background: #f0f0f0;;">
  247. <div class="row">
  248. <div class="five wide column">
  249. <span style="margin:0 6px">{{$.i18n.Tr "repo.cloudbrain_task"}}</span>
  250. </div>
  251. <div class="three wide column">
  252. <span>{{$.i18n.Tr "repo.cloudbrain_status_createtime"}}</span>
  253. </div>
  254. <div class="one wide column">
  255. <span>{{$.i18n.Tr "repo.cloudbrain_creator"}}</span>
  256. </div>
  257. <div class="seven wide column text center">
  258. <span>{{$.i18n.Tr "repo.cloudbrain_operate"}}</span>
  259. </div>
  260. </div>
  261. </div>
  262. {{range .Tasks}}
  263. <div class="ui grid stackable item">
  264. <div class="row">
  265. <!-- 任务名 -->
  266. <div class="five wide column">
  267. <a class="title" href="{{$.Link}}/{{.JobID}}" title="{{.JobName}}" style="font-size: 15px;">
  268. <span class="fitted" style="vertical-align: middle;">{{svg "octicon-tasklist" 16}}</span>
  269. <span class="fitted text_over" style="width: 90%;vertical-align: middle;margin-left: 0.4rem;">{{.JobName}}</span>
  270. </a>
  271. </div>
  272. <div class="three wide column">
  273. <!--任务状态 -->
  274. <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}">
  275. <!-- {{.Status}} -->
  276. <!-- {{if eq .Status "RUNNING"}}
  277. <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span>
  278. <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span>
  279. {{else}}
  280. {{.Status}}
  281. {{end}} -->
  282. <span><i id="{{.JobID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.JobID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span>
  283. </span>
  284. <!-- <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" >
  285. {{if eq .Status "STOPPED"}}
  286. <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">已停止</span></span>
  287. {{else if eq .Status "RUNNING"}}
  288. <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-running"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span>
  289. {{else if eq .Status "FAILED"}}
  290. <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-running"></i><span style="margin-left: 0.4em;font-size: 12px;">运行失败</span></span>
  291. {{else if eq .Status "WAITING"}}
  292. <span style="display:flex;position: relative; justify-content: flex-start;"><i class="showCircle"></i><span style="margin-left: 0.4em;font-size: 12px;">初始化等待</span></span>
  293. {{end}}
  294. </span> -->
  295. <!-- 任务创建时间 -->
  296. <span style="font-size: 12px;margin-left: 0.4rem;" class="">{{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}</span>
  297. </div>
  298. <div class="one wide column">
  299. {{if .User.Name}}
  300. <a href="{{AppSubUrl}}/{{.User.Name}}" title="{{.User.Name}}"><img class="ui avatar image" src="{{.User.RelAvatarLink}}"></a>
  301. {{else}}
  302. <a title="Ghost"><img class="ui avatar image" src="{{AppSubUrl}}/user/avatar/Ghost/-1"></a>
  303. {{end}}
  304. </div>
  305. <div class="seven wide column text right">
  306. <div class="ui compact buttons">
  307. {{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}}
  308. <a class="ui basic button" href="{{$.Link}}/{{.JobID}}/rate" target="_blank">
  309. 评分
  310. </a>
  311. {{end}}
  312. <!-- 调试 -->
  313. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  314. <a id="model-debug-{{.JobID}}" class="ui basic {{if not .CanDebug}}disabled {{else}}blue {{end}}button" href="{{$.Link}}/{{.JobID}}/debug" target="_blank">
  315. {{$.i18n.Tr "repo.debug"}}
  316. </a>
  317. {{else}}
  318. <a class="ui basic disabled button" href="{{$.Link}}/{{.JobID}}/debug" target="_blank">
  319. {{$.i18n.Tr "repo.debug"}}
  320. </a>
  321. {{end}}
  322. <form id="stopForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/stop" method="post" style="margin-left:-1px;">
  323. {{$.CsrfTokenHtml}}
  324. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  325. <a id="stop-model-debug-{{.JobID}}" class="ui basic {{if or (eq .Status "STOPPED") (eq .Status "FAILED")}}disabled {{else}}blue {{end}}button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();">
  326. {{$.i18n.Tr "repo.stop"}}
  327. </a>
  328. {{else}}
  329. <a class="ui basic disabled button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();">
  330. {{$.i18n.Tr "repo.stop"}}
  331. </a>
  332. {{end}}
  333. </form>
  334. </div>
  335. <div class="ui compact buttons" style="margin-right:10px;">
  336. <!-- 模型下载 -->
  337. <a class="ui basic blue button" href="{{$.Link}}/{{.JobID}}/models" target="_blank">
  338. {{$.i18n.Tr "repo.download"}}
  339. </a>
  340. <!-- 接收结果 -->
  341. <iframe src="" frameborder="0" name="iframeContent" style="display: none;"></iframe>
  342. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  343. <a id="model-image-{{.JobID}}" class="imageBtn ui basic {{if not .CanDebug}}disabled {{else}}blue {{end}}button" value="{{.CanDebug}}">{{$.i18n.Tr "repo.submit_image"}}</a>
  344. {{else}}
  345. <a class="imageBtn ui basic disabled button" value="{{.CanDebug}}">{{$.i18n.Tr "repo.submit_image"}}</a>
  346. {{end}}
  347. </div>
  348. <!-- 删除任务 -->
  349. <form class="ui compact buttons" id="delForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/del" method="post">
  350. {{$.CsrfTokenHtml}}
  351. {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
  352. <a id="model-delete-{{.JobID}}" class="ui compact {{if not .CanDel}}disabled {{else}}red {{end}}button" onclick="assertDelete(this)" style="border-radius: .28571429rem;">
  353. {{$.i18n.Tr "repo.delete"}}
  354. </a>
  355. {{else}}
  356. <a class="ui compact disabled button" onclick="assertDelete(this)" style="border-radius: .28571429rem;">
  357. {{$.i18n.Tr "repo.delete"}}
  358. </a>
  359. {{end}}
  360. </form>
  361. </div>
  362. <!-- 镜像列表弹窗 -->
  363. <div id="imageModal" class="modal" style="display: none;">
  364. <div class="modal-content">
  365. <!-- 表格 -->
  366. <div class="ui form">
  367. <form id="commitImageForm" action="{{$.Link}}/{{.JobID}}/commit_image" method="post" target="iframeContent">
  368. {{$.CsrfTokenHtml}}
  369. <div class="row">
  370. <p style="display: inline;">提交任务镜像</p>
  371. <span class="close">&times;</span>
  372. </div>
  373. <div class="ui divider"></div>
  374. <div class="inline required field dis">
  375. <label>镜像标签:</label>
  376. <input name="tag" id="image_tag" tabindex="3" autofocus required maxlength="255" style="width:75%">
  377. </div>
  378. <div class="inline field">
  379. <label class="label_after">镜像描述:</label>
  380. <textarea name="description" rows="8" style="width:75%;margin-left: 0.2em;"></textarea>
  381. </div>
  382. <div class="ui divider"></div>
  383. <div class="inline field">
  384. <label></label>
  385. <button class="ui green button" onclick="showmask()">
  386. {{$.i18n.Tr "repo.cloudbrain.commit_image"}}
  387. </button>
  388. </div>
  389. </form>
  390. </div>
  391. </div>
  392. </div>
  393. </div>
  394. </div>
  395. {{end}} {{template "base/paginate" .}}
  396. </div>
  397. </div>
  398. </div>
  399. </div>
  400. </div>
  401. </div>
  402. </div>
  403. </div>
  404. <!-- 确认模态框 -->
  405. <div id="deletemodel">
  406. <div class="ui basic modal">
  407. <div class="ui icon header">
  408. <i class="trash icon"></i> 删除任务
  409. </div>
  410. <div class="content">
  411. <p>你确认删除该任务么?此任务一旦删除不可恢复。</p>
  412. </div>
  413. <div class="actions">
  414. <div class="ui red basic inverted cancel button">
  415. <i class="remove icon"></i> 取消操作
  416. </div>
  417. <div class="ui green basic inverted ok button">
  418. <i class="checkmark icon"></i> 确定操作
  419. </div>
  420. </div>
  421. </div>
  422. </div>
  423. </div>
  424. {{template "base/footer" .}}
  425. <script>
  426. // 调试和评分新开窗口
  427. function stop(obj) {
  428. if (obj.style.color != "rgb(204, 204, 204)") {
  429. obj.target = '_blank'
  430. } else {
  431. return
  432. }
  433. }
  434. // 删除时用户确认
  435. function assertDelete(obj) {
  436. if (obj.style.color == "rgb(204, 204, 204)") {
  437. return
  438. } else {
  439. var delId = obj.parentNode.id
  440. flag = 1;
  441. $('.ui.basic.modal')
  442. .modal({
  443. onDeny: function() {
  444. flag = false
  445. },
  446. onApprove: function() {
  447. document.getElementById(delId).submit()
  448. flag = true
  449. },
  450. onHidden: function() {
  451. if (flag == false) {
  452. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  453. }
  454. }
  455. })
  456. .modal('show')
  457. }
  458. }
  459. // 加载任务状态
  460. var timeid = window.setInterval(loadJobStatus, 15000);
  461. $(document).ready(loadJobStatus);
  462. function loadJobStatus() {
  463. $(".job-status").each((index, job) => {
  464. const jobID = job.dataset.jobid;
  465. const repoPath = job.dataset.repopath;
  466. if (job.textContent.trim() == 'STOPPED' || job.textContent.trim() == 'FAILED') {
  467. return
  468. }
  469. $.get(`/api/v1/repos/${repoPath}/cloudbrain/${jobID}`, (data) => {
  470. const jobID = data.JobID
  471. const status = data.JobStatus
  472. if (status != job.textContent.trim()) {
  473. console.log("---------")
  474. $('#' + jobID+'-icon').removeClass().addClass(status)
  475. $('#' + jobID+ '-text').text(status)
  476. //if (status == 'STOPPED') {
  477. // window.location.reload()
  478. //}
  479. }
  480. if(status==="RUNNING"){
  481. $('#model-debug-'+jobID).removeClass('disabled')
  482. $('#model-debug-'+jobID).addClass('blue')
  483. $('#model-image-'+jobID).removeClass('disabled')
  484. $('#model-image-'+jobID).addClass('blue')
  485. }
  486. if(status!=="RUNNING"){
  487. $('#model-debug-'+jobID).removeClass('blue')
  488. $('#model-debug-'+jobID).addClass('disabled')
  489. $('#model-image-'+jobID).removeClass('blue')
  490. $('#model-image-'+jobID).addClass('disabled')
  491. }
  492. if(status!=="STOPPED" || status!=="FAILED"){
  493. $('#stop-model-debug-'+jobID).removeClass('disabled')
  494. $('#stop-model-debug-'+jobID).addClass('blue')
  495. $('#model-delete-'+jobID).removeClass('red')
  496. $('#model-delete-'+jobID).addClass('disabled')
  497. }
  498. if(status=="STOPPED" || status=="FAILED"){
  499. $('#stop-model-debug-'+jobID).removeClass('blue')
  500. $('#stop-model-debug-'+jobID).addClass('disabled')
  501. $('#model-delete-'+jobID).removeClass('disabled')
  502. $('#model-delete-'+jobID).addClass('red')
  503. }
  504. }).fail(function(err) {
  505. console.log(err);
  506. });
  507. });
  508. };
  509. // 获取弹窗
  510. var modal = document.getElementById('imageModal');
  511. // 打开弹窗的按钮对象
  512. var btns = document.getElementsByClassName("imageBtn");
  513. // 获取 <span> 元素,用于关闭弹窗
  514. var spans = document.getElementsByClassName('close');
  515. // 点击按钮打开弹窗
  516. for (i = 0; i < btns.length; i++) {
  517. btns[i].onclick = function() {
  518. modal.style.display = "block";
  519. }
  520. }
  521. // 点击 <span> (x), 关闭弹窗
  522. for (i = 0; i < spans.length; i++) {
  523. spans[i].onclick = function() {
  524. modal.style.display = "none";
  525. }
  526. }
  527. // 在用户点击其他地方时,关闭弹窗
  528. window.onclick = function(event) {
  529. if (event.target == modal) {
  530. modal.style.display = "none";
  531. }
  532. }
  533. // 显示弹窗,弹出相应的信息
  534. function showmask() {
  535. var image_tag = !$('#image_tag').val()
  536. console.log("image_tag",image_tag)
  537. if(image_tag){
  538. return
  539. }
  540. $('#imageModal').css('display', 'none')
  541. $('#mask').css('display', 'block')
  542. $("iframe[name=iframeContent]").on("load", function() {  
  543. var responseText = $("iframe")[0].contentDocument.body.getElementsByTagName("pre")[0].innerHTML; 
  544. var json1 = JSON.parse(responseText)
  545. $('#mask').css('display', 'none')
  546. parent.location.href
  547. if (json1.result_code === "0") {
  548. $('.alert').html('操作成功!').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  549. } else {
  550. $('.alert').html(json1.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(5000).fadeOut();
  551. }
  552. })
  553. }
  554. </script>