dispatch_process_edit.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>进度分配</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport"
  9. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  10. <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  11. <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  12. <style>
  13. .input {
  14. border-radius: 2px;
  15. height: 38px;
  16. border-width: 1px;
  17. border-color: lightgray;
  18. border-style: solid;
  19. background-color: white;
  20. padding-left: 3px;
  21. }
  22. .processText {
  23. margin-top: 6px;
  24. }
  25. .layui-upload-drag {
  26. padding: 10px;
  27. margin-right: 15px;
  28. }
  29. .imgsContent {
  30. display: flex;
  31. justify-content: flex-start;
  32. flex-direction: row;
  33. flex-wrap: wrap;
  34. }
  35. .image {
  36. width: 150px;
  37. height: auto;
  38. }
  39. .imgItem {
  40. margin: 0 10px;
  41. }
  42. .option {
  43. display: flex;
  44. justify-content: space-between;
  45. flex-direction: row;
  46. }
  47. .optionItem {
  48. padding: 0 13px;
  49. margin: 10px;
  50. border: 1px solid rgba(0, 0, 0, 0.1);
  51. background: #009688;
  52. color: #ffffff;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="layui-fluid">
  58. <div class="layui-row layui-col-space15">
  59. <div class="layui-card">
  60. <div class="layui-card-body" pad15>
  61. <form class="layui-form" action="" lay-filter="component-form-element">
  62. <div class="layui-row layui-col-space10 layui-form-item">
  63. <div>
  64. <label class="layui-form-label">当前进度:</label>
  65. <div class="layui-input-block processText" id="current_process"></div>
  66. </div>
  67. <div>
  68. <label class="layui-form-label">下一进度:</label>
  69. <div class="layui-input-block processText" id="next_process"></div>
  70. </div>
  71. <div>
  72. <label class="layui-form-label">服务人员:</label>
  73. <div class="layui-input-block">
  74. <select id="id_service" name="service" lay-search="">
  75. <option value="">请选择服务人员</option>
  76. </select>
  77. </div>
  78. </div>
  79. <button id="id_save" class="layui-btn" lay-submit lay-filter="component-form-element"
  80. style="display: none">保存
  81. </button>
  82. </div>
  83. </form>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <script src="../../layuiadmin/layui/layui.js"></script>
  89. <script>
  90. //即将上传的文件数组
  91. var filesList = [];
  92. //渲染的图片列表
  93. var imgsList = [];
  94. //渲染待上传的图片列表
  95. var renderImgsList = function (list) {
  96. var html = "";
  97. list.forEach((item, index) => {
  98. html += "<div class='imgItem'>\n";
  99. html += "<img src='" + item + "' class='image'>\n";
  100. html += '<div class="option">\n';
  101. html += '<div onclick="showImg(' + index + ')" class="optionItem">查看</div>\n';
  102. html += '<div onclick="deleteImg(' + index + ')" class="optionItem">删除</div>\n';
  103. html += '</div>\n';
  104. html += '</div>\n';
  105. })
  106. layui.$('#imgsList').html(html);
  107. }
  108. var showImg = function (index) {
  109. var newPage = window.open();
  110. newPage.document.write("<img src=" + imgsList[index] + " />")
  111. };
  112. var deleteImg = function (index) {
  113. filesList.splice(index, 1);
  114. imgsList.splice(index, 1);
  115. renderImgsList(imgsList);
  116. };
  117. layui.link('../../../layuiadmin/style/autocomplete.css');
  118. layui.config({
  119. base: '../../../layuiadmin/' //静态资源所在路径
  120. , autocomplete: 'autocomplete'
  121. }).extend({
  122. index: 'lib/index',
  123. }).use(['index', 'form', 'autocomplete', 'upload'], function () {
  124. var $ = layui.$
  125. , admin = layui.admin
  126. , upload = layui.upload
  127. , form = layui.form;
  128. var customer_id = layui.view.getParameterByName('customer_id');
  129. //form.render(null, 'component-form-element');
  130. var next_process_id = '';
  131. admin.req({
  132. url: '/order/get_process/?customer_id=' + customer_id
  133. , type: 'get'
  134. , done: function (res) {
  135. if (res.data.error) {
  136. layer.open({
  137. type: 1
  138. , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
  139. , id: 'layerDemo' + customer_id //防止重复弹出
  140. , content: '<div style="padding: 20px 100px;">' + res.data.error_message + '</div>'
  141. , btn: '关闭'
  142. , btnAlign: 'c' //按钮居中
  143. , shade: 0 //不显示遮罩
  144. , yes: function () {
  145. parent.layer.closeAll();
  146. }
  147. });
  148. }
  149. //当前进度
  150. $('#current_process').append(res.data.now_process_text)
  151. //下一进度
  152. $('#next_process').append(res.data.next_process_text);
  153. next_process_id = res.data.next_process_id
  154. }
  155. });
  156. //拖拽上传
  157. upload.render({
  158. elem: '#upload_img'
  159. , accept: 'file'
  160. , exts: 'jpg|png|jpeg|bmp'
  161. , acceptMime: '.jpg,.png,.jpeg,.bmp'
  162. , data: {}
  163. , multiple: true
  164. , number: 6
  165. , auto: false
  166. , choose: function (obj) {
  167. if (imgsList.length >= 6) {
  168. layer.msg("图片最多只允许上传6张", {icon: 2});
  169. return
  170. }
  171. //预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
  172. obj.preview(function (index, file, result) {
  173. filesList.push(file);
  174. imgsList.push(result);
  175. // 有图片列表的话渲染图片
  176. if (imgsList.length > 0) {
  177. renderImgsList(imgsList)
  178. }
  179. });
  180. }
  181. });
  182. form.on('submit(component-form-element)', function (data) {
  183. if (filesList.length === 0) {
  184. layer.msg("请先选择图片!", {icon: 2});
  185. return false
  186. }
  187. if (!next_process_id) {
  188. layer.msg("下个进度阶段有误,请刷新重试!", {icon: 2});
  189. return false
  190. }
  191. var formData = new FormData();
  192. formData.append("stage_progress", next_process_id);
  193. formData.append("notes", data.field.notes);
  194. filesList.forEach((item, index) => {
  195. formData.append(`file${index}`, item)
  196. });
  197. var url = '/customer/new_customer/' + customer_id + '/add_order/';
  198. admin.req({
  199. url: url
  200. , data: formData
  201. , contentType: false
  202. , processData: false
  203. , type: 'post'
  204. , done: function (res) {
  205. parent.layui.onSubmitChild(res);
  206. }
  207. });
  208. return false;
  209. });
  210. parent.layui.submitChild = function () {
  211. $("#id_save").click();
  212. };
  213. });
  214. </script>
  215. </body>
  216. </html>