qingdan.html 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6. <meta http-equiv="x-ua-compatible" content="ie=edge">
  7. <title>清单规则编辑器</title>
  8. <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
  9. <link rel="stylesheet" href="/web/maintain/bills_lib/css/main.css">
  10. <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
  11. <!--spread-->
  12. <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css">
  13. <link rel="stylesheet" href="/lib/codemirror/codemirror.css">
  14. <link rel="stylesheet" href="/lib/codemirror/material.css">
  15. </head>
  16. <body>
  17. <div class="header">
  18. <nav class="navbar navbar-toggleable-lg navbar-light bg-faded p-0 ">
  19. <span class="header-logo px-2">清单规则编辑器</span>
  20. <div class="navbar-text"></div>
  21. </nav>
  22. <nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0">
  23. <ul class="nav nav-tabs" role="tablist">
  24. <li class="nav-item">
  25. <a class="nav-link active px-3" href="javascript: void(0);">清单</a>
  26. </li>
  27. <li class="nav-item">
  28. <a id="aStdJobs" class="nav-link px-3" href="stdJobs">工作内容</a>
  29. </li>
  30. <li class="nav-item">
  31. <a id="aStdItems" class="nav-link px-3" href="stdItems">项目特征</a>
  32. </li>
  33. </ul>
  34. </nav>
  35. </div>
  36. <div class="main">
  37. <div class="content" >
  38. <div class="container-fluid">
  39. <div class="row">
  40. <div class="main-content col-lg-7 p-0">
  41. <nav class="navbar sticky-top navbar-toggleable-md navbar-light bg-faded tools-bar">
  42. <div class="collapse navbar-collapse" id="navbarNav">
  43. <ul class="navbar-nav">
  44. <li class="nav-item">
  45. <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="insert" href="javascript: void(0);"><i class="fa fa-share" aria-hidden="true"></i>插入</a>
  46. </li>
  47. <li class="nav-item">
  48. <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id ="delete" href="javascript:void (0)"><i class="fa fa-remove" aria-hidden="true"></i>删除</a>
  49. </li>
  50. <li class="nav-item">
  51. <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="upLevel" href="javascript: void(0);"><i class="fa fa-arrow-left" aria-hidden="true"></i>升级</a>
  52. </li>
  53. <li class="nav-item">
  54. <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="downLevel" href="javascript: void(0);"><i class="fa fa-arrow-right" aria-hidden="true"></i>降级</a>
  55. </li>
  56. <li class="nav-item">
  57. <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="upMove" href="javascript: void(0);"><i class="fa fa-arrow-up" aria-hidden="true"></i>上移</a>
  58. </li>
  59. <li class="nav-item">
  60. <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="downMove" href="javascript: void(0);"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
  61. </li>
  62. </ul>
  63. </div>
  64. </nav>
  65. <div class="main-data" id="spreadBills">
  66. </div>
  67. </div>
  68. <div class="main-side col-lg-5 p-0">
  69. <div class="container-fluid">
  70. <div style="width:50%; height: 100%; float: left;">
  71. <h5>工作内容</h5>
  72. <div id="spreadJobs" class="ovf-hidden" style="width:97%; height: 300px;"></div>
  73. </div>
  74. <div style="width:50%; height: 100%; float: left;">
  75. <h5>项目特征</h5>
  76. <div id="spreadItems" class="ovf-hidden" style="width: 97%; height: 300px;"></div>
  77. </div>
  78. <!-- <div class="form-group">
  79. <a class="pull-right" href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a>
  80. <label for="exampleTextarea">补注:</label>
  81. <textarea id="exampleTextarea" name="editor" class="form-control" rows="8"></textarea>
  82. </div>-->
  83. <div class="form-group">
  84. <a class="pull-right" href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a>
  85. <a trigger="billsRecharge" class="pull-right mr-3 uploadImgTrigger lock-btn-control" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a>
  86. <label for="exampleTextarea">补注:</label>
  87. <textarea class="form-control" id="exampleTextarea" rows="8"></textarea>
  88. </div>
  89. <!-- <div class="row">
  90. <div class="col ovf-hidden" style="width:50%; height: 100%; float: left;">
  91. <h5>工作内容</h5>
  92. <div id="spreadJobs" style="width:97%; height: 300px;"></div>
  93. </div>
  94. <div class="col" style="width:50%; height: 100%; float: left;">
  95. <h5>项目特征</h5>
  96. <div id="spreadItems" class="ovf-hidden" style="width: 97%; height: 300px;"></div>
  97. </div>
  98. <div class="w-100"></div>
  99. <div class="col">
  100. <div class="form-group">
  101. <label for="exampleTextarea"><h5>补注:</h5></label>
  102. <textarea class="form-control" id="exampleTextarea" rows="8"></textarea>
  103. </div>
  104. </div>
  105. </div>-->
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <!--弹出添加-->
  113. <div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
  114. <div class="modal-dialog" role="document">
  115. <div class="modal-content">
  116. <div class="modal-header">
  117. <h5 class="modal-title">添加定额</h5>
  118. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  119. <span aria-hidden="true">×</span>
  120. </button>
  121. </div>
  122. <div class="modal-body">
  123. <form>
  124. <div class="form-group">
  125. <label>编码</label>
  126. <input class="form-control" placeholder="输入编码" type="text">
  127. </div>
  128. <div class="form-group">
  129. <label>名称</label>
  130. <input class="form-control" placeholder="输入名称" type="text">
  131. </div>
  132. <div class="form-group">
  133. <label>单位</label>
  134. <select class="form-control"><option>选择单位</option><option>m3</option></select>
  135. </div>
  136. <div class="form-group">
  137. <label>基价</label>
  138. <input class="form-control" placeholder="输入基价" type="number">
  139. </div>
  140. <div class="form-group">
  141. <label>显示名称(以%s表示参数)</label>
  142. <input class="form-control" placeholder="输入显示名称" type="text">
  143. </div>
  144. <div class="form-group">
  145. <label>默认取费专业</label>
  146. <input class="form-control" placeholder="输入取费专业" type="text">
  147. </div>
  148. </form>
  149. </div>
  150. <div class="modal-footer">
  151. <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
  152. <a href="" class="btn btn-primary">添加</a>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <!--弹出编辑-->
  158. <div class="modal fade" id="edit" data-backdrop="static" style="display: none;" aria-hidden="true">
  159. <div class="modal-dialog" role="document">
  160. <div class="modal-content">
  161. <div class="modal-header">
  162. <h5 class="modal-title">编辑定额</h5>
  163. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  164. <span aria-hidden="true">×</span>
  165. </button>
  166. </div>
  167. <div class="modal-body">
  168. <form>
  169. <div class="form-group">
  170. <label>编码</label>
  171. <input class="form-control" placeholder="输入编码" type="text" value="AA0001">
  172. </div>
  173. <div class="form-group">
  174. <label>名称</label>
  175. <input class="form-control" placeholder="输入名称" type="text" value="人工挖土方">
  176. </div>
  177. <div class="form-group">
  178. <label>单位</label>
  179. <select class="form-control"><option>m3</option></select>
  180. </div>
  181. <div class="form-group">
  182. <label>基价</label>
  183. <input class="form-control" placeholder="输入基价" type="number" value="880.84">
  184. </div>
  185. <div class="form-group">
  186. <label>显示名称(以%s表示参数)</label>
  187. <input class="form-control" placeholder="输入显示名称" type="text" value="人工挖土方">
  188. </div>
  189. <div class="form-group">
  190. <label>默认取费专业</label>
  191. <input class="form-control" placeholder="输入取费专业" type="text" value="1">
  192. </div>
  193. </form>
  194. </div>
  195. <div class="modal-footer">
  196. <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
  197. <a href="" class="btn btn-primary">确定</a>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <!--弹出删除-->
  203. <div class="modal fade" id="del" data-backdrop="static" style="display: none;" aria-hidden="true">
  204. <div class="modal-dialog" role="document">
  205. <div class="modal-content">
  206. <div class="modal-header">
  207. <h5 class="modal-title">删除确认</h5>
  208. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  209. <span aria-hidden="true">×</span>
  210. </button>
  211. </div>
  212. <div class="modal-body">
  213. <h5 class="text-danger">删除后无法恢复,确认是否删除?</h5>
  214. </div>
  215. <div class="modal-footer">
  216. <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
  217. <a href="" class="btn btn-danger">删除</a>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. <!--弹出提示窗口-->
  223. <button id="alertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#alertDiv" style="display: none"></button>
  224. <div class="modal fade" id="alertDiv" data-backdrop="static" style="display: none;" aria-hidden="true">
  225. <input type="hidden" value="123">
  226. <div class="modal-dialog" role="document">
  227. <div class="modal-content">
  228. <div class="modal-header">
  229. <h5 class="modal-title">警告</h5>
  230. <button type="button" id="alertCls" class="close" data-dismiss="modal" aria-label="Close">
  231. <span aria-hidden="true">×</span>
  232. </button>
  233. </div>
  234. <div class="modal-body">
  235. <h5 class="text-danger" id="alertTxt">编号不存在,请重新输入!</h5>
  236. </div>
  237. <div class="modal-footer">
  238. <button type="button" class="btn btn-danger" id="alertCof" data-dismiss="modal">确认</button>
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. <!--删除-->
  244. <div class="modal fade" id="delAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
  245. <input type="hidden" value="123">
  246. <div class="modal-dialog" role="document">
  247. <div class="modal-content">
  248. <div class="modal-header">
  249. <h5 class="modal-title">警告</h5>
  250. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  251. <span aria-hidden="true">×</span>
  252. </button>
  253. </div>
  254. <div class="modal-body">
  255. <h5 class="text-danger" id="delText">是否删除当前清单及其子项?</h5>
  256. </div>
  257. <div class="modal-footer">
  258. <button type="button" class="btn btn-danger" id="delConfirm">确认</button>
  259. <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
  260. </div>
  261. </div>
  262. </div>
  263. </div>
  264. <!--弹出html填写帮助-->
  265. <!--弹出html填写帮助-->
  266. <div class="modal fade" id="help" style="display: none;" aria-hidden="true">
  267. <div class="modal-dialog" role="document">
  268. <div class="modal-content">
  269. <div class="modal-header">
  270. <h5 class="modal-title">html填写帮助</h5>
  271. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  272. <span aria-hidden="true">×</span>
  273. </button>
  274. </div>
  275. <div class="modal-body">
  276. <p class="text-primary">&lt;p&gt;这是一行文本&lt;/p&gt;</p>
  277. <p class="mb-0">文本居中:text-center</p>
  278. <p class="text-primary">&lt;p class="text-center" &gt;这是一行文本&lt;/p&gt;</p>
  279. <p class="mb-0">文本居右:text-right</p>
  280. <p class="text-primary">&lt;p class="text-right" &gt;这是一行文本&lt;/p&gt;</p>
  281. <p class="mb-0">文本居左(默认已居左):text-left</p>
  282. <p class="text-primary">&lt;p class="text-left" &gt;这是一行文本&lt;/p&gt;</p>
  283. <p class="mb-0">表格:table、tr、th、td</p>
  284. <p class="mb-0 text-primary">&lt;table&gt;</p>
  285. <p class="mb-0 text-primary">&lt;tr&gt;&lt;th&gt;表头1&lt;/th&gt;&lt;th&gt;表头2&lt;/th&gt;&lt;th&gt;表头3&lt;/th&gt;&lt;/tr&gt;</p>
  286. <p class="mb-0 text-primary">&lt;tr&gt;&lt;td&gt;内容1&lt;/td&gt;&lt;td&gt;内容2&lt;/td&gt;&lt;td&gt;内容3&lt;/td&gt;&lt;/tr&gt;</p>
  287. <p class="mb-0 text-primary">&lt;tr&gt;&lt;td&gt;内容4&lt;/td&gt;&lt;td&gt;内容5&lt;/td&gt;&lt;td&gt;内容6&lt;/td&gt;&lt;/tr&gt;</p>
  288. <p class="mb-0 text-primary">&lt;/table&gt;</p>
  289. <p>
  290. <table class="table table-sm table-bordered">
  291. <tr><th>表头1</th><th>表头2</th><th>表头3</th></tr>
  292. <tr><td>内容1</td><td>内容2</td><td>内容3</td></tr>
  293. <tr><td>内容4</td><td>内容5</td><td>内容6</td></tr>
  294. </table>
  295. </p>
  296. <p class="mb-0">合并横向单元格(2格):colspan="2"</p>
  297. <p class="mb-0 text-primary">&lt;table&gt;</p>
  298. <p class="mb-0 text-primary">&lt;tr&gt;&lt;th colspan="2"&gt;表头1表头2&lt;/th&gt;&lt;th&gt;表头3&lt;/th&gt;&lt;/tr&gt;</p>
  299. <p class="mb-0 text-primary">&lt;tr&gt;&lt;td&gt;内容1&lt;/td&gt;&lt;td&gt;内容2&lt;/td&gt;&lt;td&gt;内容3&lt;/td&gt;&lt;/tr&gt;</p>
  300. <p class="mb-0 text-primary">&lt;tr&gt;&lt;td&gt;内容4&lt;/td&gt;&lt;td&gt;内容5&lt;/td&gt;&lt;td&gt;内容6&lt;/td&gt;&lt;/tr&gt;</p>
  301. <p class="mb-0 text-primary">&lt;/table&gt;</p>
  302. <p>
  303. <table class="table table-sm table-bordered">
  304. <tr><th colspan="2">表头1表头2</th><th>表头3</th></tr>
  305. <tr><td>内容1</td><td>内容2</td><td>内容3</td></tr>
  306. <tr><td>内容4</td><td>内容5</td><td>内容6</td></tr>
  307. </table>
  308. </p>
  309. <p class="mb-0">合并竖向单元格(2格):rowspan="2"</p>
  310. <p class="mb-0 text-primary">&lt;table&gt;</p>
  311. <p class="mb-0 text-primary">&lt;tr&gt;&lt;th&gt;表头1&lt;/th&gt;&lt;th&gt;表头2&lt;/th&gt;&lt;th&gt;表头3&lt;/th&gt;&lt;/tr&gt;</p>
  312. <p class="mb-0 text-primary">&lt;tr&gt;&lt;td rowspan="2"&gt;内容1内容4&lt;/td&gt;&lt;td&gt;内容2&lt;/td&gt;&lt;td&gt;内容3&lt;/td&gt;&lt;/tr&gt;</p>
  313. <p class="mb-0 text-primary">&lt;tr&gt;&lt;td&gt;内容5&lt;/td&gt;&lt;td&gt;内容6&lt;/td&gt;&lt;/tr&gt;</p>
  314. <p class="mb-0 text-primary">&lt;/table&gt;</p>
  315. <p>
  316. <table class="table table-sm table-bordered">
  317. <tr><th>表头1</th><th>表头2</th><th>表头3</th></tr>
  318. <tr><td rowspan="2">内容1内容4</td><td>内容2</td><td>内容3</td></tr>
  319. <tr><td>内容5</td><td>内容6</td></tr>
  320. </table>
  321. </p>
  322. </div>
  323. <div class="modal-footer">
  324. <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. <%include ../../../common/html/uploadImg.html %>
  330. <!-- JS. -->
  331. <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
  332. <script>GC.Spread.Sheets.LicenseKey = '<%- LicenseKey %>';</script>
  333. <script src="/public/web/uuid.js"></script>
  334. <script src="/lib/jquery/jquery.min.js"></script>
  335. <script src="/lib/tether/tether.min.js"></script>
  336. <script src="/lib/bootstrap/bootstrap.min.js"></script>
  337. <script src="/web/maintain/bills_lib/scripts/global.js"></script>
  338. <script src="/public/web/PerfectLoad.js"></script>
  339. <script src="/public/web/common_ajax.js"></script>
  340. <script src="/public/web/lock_util.js"></script>
  341. <script src="/public/web/sheet/sheet_common.js"></script>
  342. <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
  343. <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
  344. <!--idTree-->
  345. <script src="/public/web/id_tree.js"></script>
  346. <script src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
  347. <script src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
  348. <script src="/web/maintain/bills_lib/scripts/bills_lib_setting.js"></script>
  349. <script src="/web/maintain/bills_lib/scripts/bills_lib_tree.js"></script>
  350. <script src="/web/maintain/bills_lib/scripts/db_controller.js"></script>
  351. <script src="/web/maintain/bills_lib/scripts/tools.js"></script>
  352. <script src="/lib/codemirror/codemirror.js"></script>
  353. <script src="/lib/codemirror/xml.js"></script>
  354. <script src="/web/common/js/uploadImg.js"></script>
  355. </body>
  356. <script type="text/javascript">
  357. const locked = lockUtil.getLocked();
  358. var codeEditor = CodeMirror.fromTextArea(document.getElementById("exampleTextarea"), {
  359. mode: "text/html",
  360. lineNumbers: true,
  361. theme:"material",
  362. readOnly: locked
  363. });
  364. codeEditor.setSize('auto','350px');
  365. autoFlashHeight();
  366. let userAccount = '<%= userAccount %>';
  367. let maxJobsNumber;
  368. let maxItemsNumber;
  369. let orgJobData;
  370. let orgItemData;
  371. let billsTree = billsLibTree.createBillsTree();
  372. let billsLibId = getQueryString("billsLibId");
  373. let sheetDatas;
  374. let sheetItemsDatas;
  375. let sheetBillsDatas;
  376. tools.redirect(billsLibId, 'stdBillsmain');
  377. let billsSpread;
  378. let jobsSpread = new GC.Spread.Sheets.Workbook($("#spreadJobs")[0], {sheetCount: 1});
  379. jobsSpread.options.allowUserDragFill = false;
  380. sheetCommonObj.bindEscKey(jobsSpread, [{sheet: jobsSpread.getSheet(0), editStarting: jobsController.onEditStart, editEnded: jobsController.onEditEnded}]);
  381. let itemsSpread = new GC.Spread.Sheets.Workbook($("#spreadItems")[0], {sheetCount: 1});
  382. itemsSpread.options.allowUserDragFill = false;
  383. sheetCommonObj.bindEscKey(itemsSpread, [{sheet: itemsSpread.getSheet(0), editStarting: itemsController.onEditStart, editEnded: itemsController.onEditEnded}]);
  384. $(document).ready(function(){
  385. $("#aStdJobs").attr('href', function(){
  386. return `stdJobs?billsLibId=${billsLibId}&locked=${locked}`;
  387. });
  388. $('#aStdItems').attr('href', function(){
  389. return `stdItems?billsLibId=${billsLibId}&locked=${locked}`;
  390. });
  391. billsAjax.getStdBillsLibName(billsLibId);
  392. billsAjax.getBills(billsLibId, function(bills){
  393. showBillsSheet(bills, jobsSpread.getActiveSheet(), itemsSpread.getActiveSheet(), billsLibSetting)
  394. const spreads = [billsSpread, jobsSpread, itemsSpread];
  395. const $range = $(document.body);
  396. lockUtil.lockSpreadsAndTools(spreads, $range, locked);
  397. });
  398. buildJobs(jobsSpread, jobsSetting);
  399. buildItems(itemsSpread, itemsSetting);
  400. });
  401. function nodeOpration(controller, totalJobs, totalItems){
  402. let btnInsert = $('#insert');
  403. let btnDelete = $('#delete');
  404. let btnUpLevel = $('#upLevel');
  405. let btnDownLevel = $('#downLevel');
  406. let btnUpMove = $('#upMove');
  407. let btnDownMove = $('#downMove');
  408. dbController.editData(controller);
  409. btnInsert.click(function(){
  410. if(btnInsert.attr('doing') === 'false' && btnInsert.attr('fcsOnBills') === 'true'){
  411. dbController.insert(controller, btnInsert);
  412. tools.clearData(jobsSpread.getActiveSheet());
  413. tools.clearData(itemsSpread.getActiveSheet());
  414. }
  415. });
  416. //删除清单
  417. $('#delConfirm').click(function () {
  418. dbController.delete(controller, btnDelete, totalJobs, totalItems);
  419. $('#delAlert').modal('hide');
  420. });
  421. btnDelete.click(function(){
  422. if(btnDelete.attr('doing') === 'false' && btnDelete.attr('fcsOnBills') === 'true'){
  423. $('#delAlert').modal('show');
  424. }
  425. });
  426. btnUpLevel.click(function(){
  427. if(btnUpLevel.attr('doing') === 'false' && btnUpLevel.attr('fcsOnBills') === 'true'){
  428. dbController.upLevel(controller, btnUpLevel);
  429. }
  430. });
  431. btnDownLevel.click(function(){
  432. if(btnDownLevel.attr('doing') === 'false' && btnDownLevel.attr('fcsOnBills') === 'true'){
  433. dbController.downLevel(controller, btnDownLevel);
  434. }
  435. });
  436. btnUpMove.click(function(){
  437. if(btnUpMove.attr('doing') === 'false' && btnUpMove.attr('fcsOnBills') === 'true'){
  438. dbController.upMove(controller, btnUpMove);
  439. }
  440. //refSheet
  441. else if(btnUpMove.attr('doing') === 'false' && btnUpMove.attr('fcsOnBills') === 'false' && btnUpMove.attr('canMove') === 'true'){
  442. if(controller.tree.selected.field === 'job'){
  443. jobsController.upMove(controller, jobsSpread.getActiveSheet());
  444. }
  445. else if(controller.tree.selected.field === 'item'){
  446. itemsController.upMove(controller, itemsSpread.getActiveSheet());
  447. }
  448. }
  449. });
  450. btnDownMove.click(function(){
  451. if(btnDownMove.attr('doing') === 'false' && btnDownMove.attr('fcsOnBills') === 'true'){
  452. dbController.downMove(controller, btnDownMove);
  453. }
  454. else if(btnDownMove.attr('doing') === 'false' && btnDownMove.attr('fcsOnBills') === 'false' && btnDownMove.attr('canMove') === 'true'){
  455. if(controller.tree.selected.field === 'job'){
  456. jobsController.downMove(controller, jobsSpread.getActiveSheet());
  457. }
  458. else if(controller.tree.selected.field === 'item'){
  459. itemsController.downMove(controller, itemsSpread.getActiveSheet());
  460. }
  461. }
  462. });
  463. }
  464. function showBillsSheet(datas, jobsSheet, itemsSheet, setting) {
  465. billsSpread = new GC.Spread.Sheets.Workbook($('#spreadBills')[0], {sheetCount: 1});
  466. sheetCommonObj.bindEscKey(billsSpread, [{sheet: billsSpread.getSheet(0), editStarting: dbController.onEditStart, editEnded: dbController.onEditEnded}]);
  467. billsSpread.focus(true);
  468. setSheet.initSheet(billsSpread, setting, true);
  469. myKey.delKey(billsSpread);
  470. billsTree.loadDatas(datas);
  471. let controller = TREE_SHEET_CONTROLLER.createNew(billsTree.tree, billsSpread.getActiveSheet(), setting);
  472. controller.showTreeData();
  473. dbController.controller = controller;
  474. sheetBillsDatas = tools.getsheetDatas(controller.sheet, 'bills', controller);
  475. setSheet.formatter(billsSpread.getActiveSheet());
  476. const codeCol = setting.cols.findIndex(item => item.data.field ==='code');
  477. billsSheet.setFormatter(-1, codeCol, '@', GC.Spread.Sheets.SheetArea.viewport);
  478. //setTagId
  479. setTagID(controller, setting);
  480. if (!controller.tree.selected && controller.tree.findNode(controller.sheet.getTag(0, 0, GC.Spread.Sheets.SheetArea.viewport))) {
  481. controller.setTreeSelected(controller.tree.findNode(controller.sheet.getTag(0, 0, GC.Spread.Sheets.SheetArea.viewport)));
  482. }
  483. //刷新节点可进行操作的按钮
  484. refreshBtn(controller);
  485. controller.setTreeSelected(controller.tree.findNode(controller.sheet.getTag(0, 0)));
  486. //粘贴事件
  487. bindPasteBills(controller, billsSpread.getActiveSheet(), setting);
  488. bindBillsRangeChanged(controller, billsSpread.getActiveSheet(), setting);
  489. //补注内容改变
  490. rechargeChange(controller);
  491. //焦点控制
  492. switchFcs(controller, controller.sheet, billsSpread, jobsSheet, itemsSheet);
  493. //jobs
  494. jobOperation(controller, jobsSheet, function(totalJobs){
  495. //------关联表粘贴复制
  496. bindPasteRel(jobsSheet, controller, totalJobs, jobsSetting);
  497. //items
  498. itemOperation(controller, itemsSheet, function(totalItems){
  499. bindPasteItemsRel(itemsSheet, controller, totalItems, itemsSetting);
  500. //节点操作
  501. nodeOpration(controller, totalJobs, totalItems);
  502. });
  503. });
  504. }
  505. function switchFcs(controller, billsSheet, billsSpread, jobsSheet, itemsSheet){
  506. let btnInsert = $('#insert');
  507. let btnDelete = $('#delete');
  508. let btnUpMove = $('#upMove');
  509. let btnDownMove = $('#downMove');
  510. let btnUpLevel = $('#upLevel');
  511. let btnDownLevel = $('#downLevel');
  512. billsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
  513. jobsSheet.clearSelection();
  514. itemsSheet.clearSelection();
  515. billsSpread.focus(true);
  516. jobsSheet.options.isProtected = true;
  517. itemsSheet.options.isProtected = true;
  518. billsSheet.options.isProtected = false;
  519. btnInsert.attr('fcsOnBills', 'true');
  520. btnDelete.attr('fcsOnBills', 'true');
  521. btnUpLevel.attr('fcsOnBills', 'true');
  522. btnDownLevel.attr('fcsOnBills', 'true');
  523. btnUpMove.attr('fcsOnBills', 'true');
  524. btnDownMove.attr('fcsOnBills', 'true');
  525. });
  526. jobsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
  527. itemsSheet.clearSelection();
  528. jobsSpread.focus(true);
  529. itemsSheet.options.isProtected = true;
  530. billsSheet.options.isProtected = true;
  531. jobsSheet.options.isProtected = false;
  532. controller.tree.selected.args = args;
  533. controller.tree.selected.field = 'job';
  534. tools.btnClose(btnInsert);
  535. tools.btnClose(btnDelete);
  536. tools.btnClose(btnUpLevel);
  537. tools.btnClose(btnDownLevel);
  538. btnInsert.attr('fcsOnBills', 'false');
  539. btnDelete.attr('fcsOnBills', 'false');
  540. btnUpLevel.attr('fcsOnBills', 'false');
  541. btnDownLevel.attr('fcsOnBills', 'false');
  542. btnUpMove.attr('fcsOnBills', 'false');
  543. btnDownMove.attr('fcsOnBills', 'false');
  544. let selected;
  545. if(controller.tree.selected){
  546. selected = controller.tree.selected.jobs[args.row];
  547. }
  548. if(tools.canUpMove(selected, controller.tree.selected.jobs)){
  549. tools.btnAction(btnUpMove);
  550. btnUpMove.attr('canMove', 'true');
  551. }
  552. else{
  553. tools.btnClose(btnUpMove);
  554. btnUpMove.attr('canMove', 'false');
  555. }
  556. if(tools.canDownMove(selected, controller.tree.selected.jobs)){
  557. tools.btnAction(btnDownMove);
  558. btnDownMove.attr('canMove', 'true');
  559. }
  560. else{
  561. tools.btnClose(btnDownMove);
  562. btnDownMove.attr('canMove', 'false');
  563. }
  564. });
  565. itemsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
  566. jobsSheet.clearSelection();
  567. itemsSpread.focus(true);
  568. jobsSheet.options.isProtected = true;
  569. billsSheet.options.isProtected = true;
  570. itemsSheet.options.isProtected = false;
  571. controller.tree.selected.args = args;
  572. controller.tree.selected.field = 'item';
  573. tools.btnClose(btnInsert);
  574. tools.btnClose(btnDelete);
  575. tools.btnClose(btnUpLevel);
  576. tools.btnClose(btnDownLevel);
  577. btnInsert.attr('fcsOnBills', 'false');
  578. btnDelete.attr('fcsOnBills', 'false');
  579. btnUpLevel.attr('fcsOnBills', 'false');
  580. btnDownLevel.attr('fcsOnBills', 'false');
  581. btnUpMove.attr('fcsOnBills', 'false');
  582. btnDownMove.attr('fcsOnBills', 'false');
  583. let selected;
  584. if(controller.tree.selected){
  585. selected = controller.tree.selected.items[args.row];
  586. }
  587. if(tools.canUpMove(selected, controller.tree.selected.items)){
  588. tools.btnAction(btnUpMove);
  589. btnUpMove.attr('canMove', 'true');
  590. }
  591. else{
  592. tools.btnClose(btnUpMove);
  593. btnUpMove.attr('canMove', 'false');
  594. }
  595. if(tools.canDownMove(selected, controller.tree.selected.items)){
  596. tools.btnAction(btnDownMove);
  597. btnDownMove.attr('canMove', 'true');
  598. }
  599. else{
  600. tools.btnClose(btnDownMove);
  601. btnDownMove.attr('canMove', 'false');
  602. }
  603. });
  604. };
  605. function setTagID(controller, setting){
  606. if(controller.tree.items.length > 0){
  607. let length = controller.tree.items.length;
  608. for(var i=0; i<length; i++){
  609. setting.cols.forEach(function(col, colIdx){
  610. if(controller.tree.items[i].data.ID){
  611. controller.sheet.setTag(i, colIdx, controller.tree.items[i].data.ID);
  612. }
  613. });
  614. }
  615. }
  616. }
  617. function refreshBtn(controller){
  618. if (locked) {
  619. return;
  620. }
  621. controller.bind('refreshBaseActn', function (tree) {
  622. let showButton = function (show, btn) {
  623. tools.btnAction($('#insert'), 'focusOnBills');
  624. if (show) {
  625. tools.btnAction(btn, 'doing');
  626. } else {
  627. tools.btnClose(btn, 'doing');
  628. }
  629. };
  630. showButton(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
  631. showButton(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
  632. showButton(tree.selected && tree.selected.canUpMove(), $('#upMove'));
  633. showButton(tree.selected && tree.selected.canDownMove(), $('#downMove'));
  634. showButton(tree.selected ? true : false, $('#delete'));
  635. });
  636. }
  637. function rechargeChange(controller){
  638. codeEditor.on("change", function () {
  639. if(controller.tree.selected){
  640. let newData = codeEditor.getValue();
  641. if(newData !== controller.tree.selected.data.recharge){
  642. rechargeController.updateRechar(controller.tree.selected, newData);
  643. }
  644. }
  645. });
  646. /*$('#exampleTextarea').bind('change', function(){
  647. let newData = $('#exampleTextarea').val();
  648. if(controller.tree.selected){
  649. console.log(controller.tree.selected.data.code)
  650. rechargeController.updateRechar(controller.tree.selected, newData);
  651. }
  652. });*/
  653. }
  654. function jobOperation(controller, jobsSheet, callback){
  655. mainAjax.getMaxNumber(billsLibId, 'jobs', function(result){
  656. if(result.length === 0){
  657. maxJobsNumber = 0;
  658. }
  659. else {
  660. maxJobsNumber = result[0].code;
  661. }
  662. jobsAjax.getJobContent(billsLibId, function(datas){
  663. let totalJobs = createObj.newJobs();
  664. totalJobs.loadJobs(controller.tree.items, datas);
  665. jobsController.totalJobs = totalJobs;
  666. initData(controller, jobsSheet, jobsSetting, 'jobs');
  667. myKey.delKey(jobsSpread, controller, totalJobs, jobsSetting, 'jobs');
  668. bindSheet(controller, jobsSheet, 'jobs', jobsSetting);
  669. jobsController.editData(jobsSheet);
  670. if (callback){
  671. callback(totalJobs);
  672. }
  673. });
  674. });
  675. }
  676. function itemOperation(controller, itemsSheet, callback){
  677. mainAjax.getMaxNumber(billsLibId, 'items', function(result){
  678. if(result.length === 0){
  679. maxItemsNumber = 0;
  680. }
  681. else {
  682. maxItemsNumber = result[0].code;
  683. }
  684. itemsAjax.getItemCharacter(billsLibId, function(datas){
  685. let totalItems = createObj.newItems();
  686. totalItems.loadItems(controller.tree.items, datas);
  687. itemsController.totalItems = totalItems;
  688. initData(controller, itemsSheet, itemsSetting, 'items');
  689. myKey.delKey(itemsSpread, controller, totalItems, itemsSetting, 'items');
  690. bindSheet(controller, itemsSheet, 'items', itemsSetting);
  691. itemsController.editData(itemsSheet);
  692. if(callback){
  693. callback(totalItems)
  694. }
  695. });
  696. });
  697. }
  698. //初始焦点工作表和项目表绑定数据
  699. function initData(controller, sheet, setting, classify){
  700. if(controller.tree.selected){
  701. let arr = controller.tree.selected[classify];
  702. let recharge = controller.tree.selected.data.recharge;
  703. let prefix = classify === 'jobs' ? 'job' : 'item';
  704. if(arr.length > 0){
  705. tools.orderReshowData(sheet, arr, setting, prefix,true);
  706. }
  707. else{
  708. setSheet.setMaxRowCount(sheet, []);
  709. }
  710. if(recharge){
  711. codeEditor.setValue(recharge);
  712. //$('#exampleTextarea').val(recharge);
  713. }
  714. else{
  715. codeEditor.setValue('');
  716. //$('#exampleTextarea').val('');
  717. }
  718. }
  719. }
  720. function bindSheet(controller, sheet, field, setting){
  721. controller.sheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function(sender, args){
  722. if(args.newSelections[0]){
  723. controller.tree.selected = controller.tree.items[args.newSelections[0].row] ? controller.tree.items[args.newSelections[0].row] : null;
  724. }
  725. if(controller.tree.selected && args.oldSelections[0].row !== args.newSelections[0].row|| controller.tree.selected && args.oldSelections[0].row === 0){
  726. //rechargeArea
  727. const recharge = controller.tree.selected.data.recharge || '';
  728. codeEditor.setValue(recharge);
  729. //$('#exampleTextarea').val(controller.tree.selected.data.recharge);
  730. if(field === 'jobs'){
  731. tools.clearData(sheet);
  732. let jobs = controller.tree.selected.jobs;
  733. setSheet.setMaxRowCount(sheet, jobs);
  734. if(jobs.length > 0){
  735. tools.orderReshowData(sheet, jobs, setting, 'job', true);
  736. orgJobData = sheet.getValue(0, 0);
  737. }
  738. //sheetDatas = tools.getsheetDatas(sheet, 'jobs');
  739. }
  740. if(field === 'items'){
  741. tools.clearData(sheet);
  742. let items = controller.tree.selected.items;
  743. setSheet.setMaxRowCount(sheet, items);
  744. if(items.length > 0){
  745. tools.orderReshowData(sheet, items, setting, 'item', true);
  746. orgItemData = sheet.getValue(0, 0);
  747. }
  748. //sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
  749. }
  750. }
  751. });
  752. }
  753. function bindPasteBills(controller, sheet, setting){
  754. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
  755. sheetBillsDatas = tools.getsheetDatas(sheet, 'bills', controller);
  756. let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
  757. //复制的列数超过正确的列数,不可复制
  758. if(maxCol >= billsLibSetting.cols.length){
  759. args.cancel = true;
  760. }
  761. });
  762. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
  763. let datas = [], field;
  764. let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
  765. let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
  766. let markRow = orgRow, colLen = sheet.getColumnCount(GC.Spread.Sheets.SheetArea.viewport);
  767. let validDatas = tools.getValidDatas(sheet, setting, args);
  768. sheet.suspendPaint();
  769. for(let i =orgRow, j=0; i<= maxRow; i++, j++){
  770. //let id = controller.tree.items[i] ? controller.tree.items[i].getID() : null;
  771. let id = sheet.getTag(i, 0);
  772. if(id && j< validDatas.length){
  773. validDatas[j].ID = id;
  774. for(let k =orgCol; k<= maxCol; k++){
  775. setting.cols.forEach(function(col, colIdx){
  776. if(colIdx === k){
  777. if(validDatas[j][col.data.field]){
  778. sheet.setValue(i, k, validDatas[j][col.data.field]);
  779. sheetBillsDatas.datasIdx['rowIdx'+ i][col.data.field] = validDatas[j][col.data.field];
  780. }
  781. else {
  782. sheet.setValue(i, k, '');
  783. sheetBillsDatas.datasIdx['rowIdx'+ i][col.data.field] = '';
  784. }
  785. }
  786. });
  787. }
  788. }
  789. else if(i < controller.tree.items.length && j>= validDatas.length){
  790. //reshow orgDatas
  791. sheet.setValue(i, 0, sheetBillsDatas.datasIdx['rowIdx'+ i].code + '');
  792. sheet.setValue(i, 1, sheetBillsDatas.datasIdx['rowIdx'+ i].name);
  793. sheet.setValue(i, 2, sheetBillsDatas.datasIdx['rowIdx'+ i].unit);
  794. sheet.setValue(i, 3, sheetBillsDatas.datasIdx['rowIdx'+ i].ruleText);
  795. sheet.setValue(i, 4, sheetBillsDatas.datasIdx['rowIdx'+ i].engineering);
  796. }
  797. else {
  798. sheet.clear(i, 0, 1, sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport,GC.Spread.Sheets.StorageType.data);
  799. }
  800. }
  801. sheet.resumePaint();
  802. billsAjax.pasteBills(userAccount, billsLibId, validDatas);
  803. for(let vData of validDatas){
  804. let node = controller.tree.nodes['id_' + vData.ID];
  805. if(node){
  806. Object.assign(node.data, vData);
  807. }
  808. }
  809. sheet.setRowCount(sheetBillsDatas.datas.length);
  810. });
  811. }
  812. function bindBillsRangeChanged(controller, sheet, setting) {
  813. sheet.bind(GC.Spread.Sheets.Events.RangeChanged, function (sender, info) {
  814. const postData = [];
  815. let curRow;
  816. let curData;
  817. info.changedCells.forEach(({ row, col }) => {
  818. const node = controller.tree.items[row];
  819. if (curRow !== row) {
  820. curData = { ID: node.data.ID };
  821. postData.push(curData);
  822. }
  823. curRow = row;
  824. const field = setting.cols[col].data.field;
  825. const value = sheet.getValue(row, col);
  826. curData[field] = value;
  827. });
  828. billsAjax.pasteBills(userAccount, billsLibId, postData, function () {
  829. info.changedCells.forEach(({ row, col }) => {
  830. const node = controller.tree.items[row];
  831. const field = setting.cols[col].data.field;
  832. const value = sheet.getValue(row, col);
  833. node.data[field] = value;
  834. sheetBillsDatas.datasIdx['rowIdx' + row][field] = value;
  835. });
  836. }, function () {
  837. info.changedCells.forEach(({ row, col }) => {
  838. const node = controller.tree.items[row];
  839. const field = setting.cols[col].data.field;
  840. sheet.setValue(row, col, node.data[field] || '');
  841. });
  842. });
  843. });
  844. }
  845. function bindPasteRel(sheet, controller, totalJobs, setting){
  846. //sheetDatas = tools.getsheetDatas(sheet, 'jobs');
  847. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
  848. let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
  849. sheetDatas = tools.getsheetDatas(sheet, 'jobs');
  850. //复制的列数超过正确的列数,不可复制
  851. if(maxCol >= jobsSetting.cols.length){
  852. args.cancel = true;
  853. }
  854. });
  855. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
  856. if(controller.tree.selected){
  857. let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
  858. let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
  859. let pasteArr = [];
  860. let crossedDatas = [];
  861. let uncrossedDatas = [];
  862. const codeCol = 0;
  863. const contentCol = 1;
  864. for(let i=orgRow; i<=maxRow; i++){
  865. //粘贴编号列,转换成粘贴内容处理
  866. let code = sheet.getCell(i, codeCol).value();
  867. let content = sheet.getCell(i, contentCol).value();
  868. if(code && !content){
  869. let contentByCode = tools.getContentByCode(totalJobs.jobsArr, code);
  870. if(contentByCode){
  871. pasteArr.push(contentByCode);
  872. }
  873. }
  874. if(content){
  875. pasteArr.push(content);
  876. }
  877. }
  878. let uniqPasteArr = tools.uniqArr(pasteArr);
  879. let serialNoUn = tools.getSerialNo(controller.tree.selected.jobs) - 1;
  880. for(let i =orgRow, j=0; i<=uniqPasteArr.length+orgRow-1; i++, j++ ){
  881. let flag = true;
  882. let crossedData;
  883. sheetDatas.forEach(function(rowData){
  884. if(rowData.rowIdx === i && rowData.data !== uniqPasteArr[j]){
  885. flag = false;
  886. let serialNo = tools.getObj(controller.tree.selected.jobs, rowData.id, 'job');
  887. crossedData = {
  888. orgId: rowData.id,
  889. newData: uniqPasteArr[j],
  890. serialNo: serialNo
  891. };
  892. }
  893. });
  894. if(flag){
  895. serialNoUn++;
  896. uncrossedDatas.push({data: uniqPasteArr[j], serialNo: serialNoUn});
  897. }
  898. else {
  899. crossedDatas.push(crossedData);
  900. }
  901. }
  902. let pasteDatas = tools.encapData(uncrossedDatas, crossedDatas, controller, totalJobs);
  903. if(pasteDatas.updateDatas.length > 0 || pasteDatas.createDatas.length > 0){
  904. billsAjax.pasteRel(userAccount, billsLibId, pasteDatas.updateDatas, pasteDatas.createDatas, 'jobs', function(datas){
  905. pasteController.frontOperator(sheet, setting, controller, totalJobs, datas);
  906. });
  907. }
  908. else {
  909. tools.orderReshowData(sheet, controller.tree.selected.jobs, setting, 'job', true);
  910. }
  911. }
  912. else {
  913. tools.clearData(sheet);
  914. }
  915. });
  916. }
  917. function bindPasteItemsRel(sheet, controller, totalItems, setting){
  918. //sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
  919. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
  920. let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
  921. sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
  922. //复制的列数超过正确的列数,不可复制
  923. if(maxCol >= itemsSetting.cols.length){
  924. args.cancel = true;
  925. }
  926. });
  927. sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
  928. if(controller.tree.selected){
  929. let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
  930. let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
  931. let pasteArr = [];
  932. let crossedDatas = [];
  933. let uncrossedDatas = [];
  934. const codeCol = 0;
  935. const contentCol = 1;
  936. for(let i=orgRow; i<=maxRow; i++){
  937. //编号列转换成内容列处理
  938. let code = sheet.getCell(i, codeCol).value();
  939. let content = sheet.getCell(i, contentCol).value();
  940. if(code && !content){
  941. let contentByCode = tools.getContentByCode(totalItems.itemsArr, code);
  942. if(contentByCode){
  943. pasteArr.push(contentByCode);
  944. }
  945. }
  946. if(content){
  947. pasteArr.push(content);
  948. }
  949. }
  950. let uniqPasteArr = tools.uniqArr(pasteArr);
  951. let serialNoUn = tools.getSerialNo(controller.tree.selected.items) - 1;
  952. for(let i =orgRow, j=0; i<=uniqPasteArr.length+orgRow-1; i++, j++ ){
  953. let flag = true;
  954. let crossedData;
  955. sheetItemsDatas.forEach(function(rowData){
  956. if(rowData.rowIdx === i && rowData.data !== uniqPasteArr[j]){
  957. flag = false;
  958. let serialNo = tools.getObj(controller.tree.selected.items, rowData.id, 'item');
  959. crossedData = {
  960. orgId: rowData.id,
  961. newData: uniqPasteArr[j],
  962. serialNo: serialNo
  963. };
  964. }
  965. });
  966. if(flag){
  967. serialNoUn ++;
  968. uncrossedDatas.push({data: uniqPasteArr[j], serialNo: serialNoUn});
  969. }
  970. else {
  971. crossedDatas.push(crossedData);
  972. }
  973. }
  974. let pasteDatas = tools.encapItemsData(uncrossedDatas, crossedDatas, controller, totalItems);
  975. if(pasteDatas.updateDatas.length > 0 || pasteDatas.createDatas.length > 0){
  976. billsAjax.pasteRel(userAccount, billsLibId, pasteDatas.updateDatas, pasteDatas.createDatas, 'items', function(datas){
  977. pasteController.frontItemsRelOperator(sheet, setting, controller, totalItems, datas);
  978. });
  979. }
  980. else{
  981. tools.orderReshowData(sheet, controller.tree.selected.items, setting, 'item', true);
  982. }
  983. }
  984. else {
  985. tools.clearData(sheet);
  986. }
  987. });
  988. }
  989. function buildJobs(jobsSpread, setting){
  990. setSheet.initSheet(jobsSpread, setting, true);
  991. jobsSpread.getActiveSheet().clearSelection();
  992. myKey.downKey(jobsSpread);
  993. myKey.enterKey(jobsSpread);
  994. TREE_SHEET_HELPER.loadSheetHeader(jobsSetting, jobsSpread.getActiveSheet());
  995. }
  996. function buildItems(itemsSpread, setting){
  997. setSheet.initSheet(itemsSpread, setting, true);
  998. // setSheet.setMaxRowCount(itemsSpread.getActiveSheet(), 10);
  999. itemsSpread.getActiveSheet().clearSelection();
  1000. myKey.downKey(itemsSpread);
  1001. myKey.enterKey(itemsSpread);
  1002. TREE_SHEET_HELPER.loadSheetHeader(itemsSetting, itemsSpread.getActiveSheet());
  1003. }
  1004. </script>
  1005. </html>