SceneFlow.cshtml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. @using WePlatform.Configuration
  2. @using WePlatform.Authorization
  3. @using WePlatform.Views.Shared.Modals
  4. @using WePlatform.Views.Shared.Query
  5. @using WePlatform.Views.Shared.SearchForm
  6. @using WePlatform.Views.Shared.Table
  7. @{
  8. ViewBag.Title = "演练情景流策划";
  9. string activeMenu = PermissionNames.PagesWePlayerMgFlowMg; //The menu item will be active for this page.
  10. ViewBag.ActiveMenu = activeMenu;
  11. string category = ViewBag.Category, sceneType = ViewBag.SceneType, guideType = ViewBag.GuideType,
  12. flowState = "<option value=\"\" selected>请选择情景流状态...</option><option value=\"" + SceneFlowStateDefinition.New + "\">新建</option><option value=\"" + SceneFlowStateDefinition.Solidified + "\">已固化</option>";
  13. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  14. {
  15. new SearchItem("flowName","流名称"),
  16. //new SearchItem("sceneCategory","场景类别").SetSelectItem(category,isTree:true),
  17. new SearchItem("sceneFlowState","流状态",FieldType.I).SetSelectItem(flowState),
  18. });
  19. var table = new TableViewModel(IwbConsts.ApiAppUrl + "SceneFlow/GetAll", activeMenu, searchForm)
  20. .SetFields(new List<FieldItem>()
  21. {
  22. new FieldItem("id", "编码"),
  23. new FieldItem("flowName", "情景流名称"),
  24. new FieldItem("sceneCategoryName", "类别名称",isSort:false),
  25. //new FieldItem("sceneFlowState", "情景流状态","FlowStateFormatter"),
  26. });
  27. }
  28. @section css{
  29. <link href="~/Content/Libs/jstree/themes/proton/style.min.css" rel="stylesheet" />
  30. }
  31. <div class="row">
  32. <div class="col-sm-3">
  33. <div class="iwb-tree-box">
  34. <div class="box-header">场景类别</div>
  35. <div class="scroll box-body">
  36. <div id="sc-tree"></div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="col-sm-9">
  41. @Html.Partial("Table/_Table", table)
  42. </div>
  43. </div>
  44. @section modal{
  45. <!--Main Modal-->
  46. <section>
  47. <div class="modal fade show" id="modal" tabindex="-1" aria-modal="true">
  48. <div class="modal-dialog modal-lg" style="max-width: 1300px;">
  49. <div class="modal-content">
  50. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("情景流"))
  51. <div class="modal-body" style="padding: 0">
  52. <form class="form-horizontal " id="form" style="padding-top: 10px">
  53. <input type="hidden" id="id" name="id" value="" />
  54. <div class="form-group row">
  55. <label class="col-sm-1 iwb-label iwb-label-sm iwb-label-required" for="flowName">情景流名称</label>
  56. <div class="col-sm-5">
  57. <div class="input-group input-group-sm">
  58. <input class="form-control required" id="flowName" name="flowName" type="text" placeholder="请输入情景流名称..." style="" aria-required="true">
  59. </div>
  60. </div>
  61. <label class="col-sm-1 iwb-label iwb-label-sm iwb-label-required" for="sceneCategory">场景类别</label>
  62. <div class="col-sm-5">
  63. <div class="input-group input-group-sm">
  64. <select class="form-control required" id="sceneCategory" name="sceneCategory" placeholder="请输入场景类别..." style="width: 100%" aria-required="true">
  65. @(Html.Raw(category))
  66. </select>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="main-box main-flow-box">
  71. </div>
  72. </form>
  73. </div>
  74. @Html.Partial("Modals/_ModalFooter", "0")
  75. </div>
  76. </div>
  77. </div>
  78. </section>
  79. @Html.Partial("_FlowNode","flow")
  80. @Html.Partial("Query/_SceneInfo", new QueryWithSelect("sceneNos,sceneNames,variables", new Dictionary<string, string>
  81. {
  82. ["sceneCategory"] = category,
  83. ["sceneType"] = sceneType,
  84. }))
  85. @Html.Partial("Query/_GuideInfo", new QueryWithSelect("guideNos,guideNames", new Dictionary<string, string>() { ["guideType"] = guideType }))
  86. @{
  87. var solidifyModal = new ModalViewModel("固化情景流", "", new ModalBodyViewModel(new List<Input>
  88. {
  89. new InputHide("id"),
  90. new Input("newName","固化名称"),
  91. }, "form-solidify"), "modal-solidify");
  92. }
  93. @Html.Partial("Modals/_Modal",solidifyModal)
  94. }
  95. @section scripts
  96. {
  97. <script src="~/Content/Libs/jstree/jstree.min.js"></script>
  98. <script type="text/javascript">
  99. var $table, _IsDetail = false, cuScNo='';
  100. $(function() {
  101. OverlayScrollbar($('.scroll'));
  102. InitScTree();
  103. $('#modal #flowName').on('change',function() {
  104. var data = $.extend({}, window._FlowTreeData, { name: $('#modal #flowName').val() ? $('#modal #flowName').val():'根节点'});
  105. window.InitFlowTree(data);
  106. });
  107. $table = LoadTable({
  108. searchFun: TableSearchFun
  109. });
  110. var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
  111. funs["btnCreate"] = function () {
  112. BtnCreate({
  113. data: { id: "" },
  114. dataFun: GetSaveData,
  115. select2tree: "sceneCategory",
  116. shownAfter: function () {
  117. window._CompData = [];
  118. var initData = window.GetInitData();
  119. var data = $.extend({}, initData, { name: $('#modal #flowName').val() ? $('#modal #flowName').val():'根节点'});
  120. window.InitFlowTree(data);
  121. }
  122. });
  123. }
  124. funs["btnUpdate"] = function () {
  125. var row = $table.bootstrapTable("getSelections")[0];
  126. if (row) {
  127. if (row.sceneFlowState==@(SceneFlowStateDefinition.Solidified)) {
  128. abp.message.warn("方案包已固化不能修改!");
  129. return;
  130. }
  131. BtnUpdate({
  132. select2tree: "sceneCategory",
  133. dataFun: GetSaveData,
  134. disabled: "",
  135. shownAfter: function () {
  136. var data;
  137. try {
  138. data = row.contentInfo ? JSON.parse(row.contentInfo) : undefined;
  139. window._CompData = row.componentInfo ? JSON.parse(row.componentInfo) : [];
  140. console.log("U-JSON:", data, window._CompData);
  141. } catch (e) {
  142. console.log(e);
  143. }
  144. if (!data) {
  145. var initData = window.GetInitData();
  146. data = $.extend({}, initData);
  147. }
  148. window.InitFlowTree(data);
  149. }
  150. });
  151. } else {
  152. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  153. }
  154. };
  155. funs["btnDelete"] = function(url) {
  156. var row = $table.bootstrapTable("getSelections")[0];
  157. if (row) {
  158. if (row.sceneFlowState==@(SceneFlowStateDefinition.Solidified)) {
  159. abp.message.warn("方案包已固化不能删除!");
  160. return;
  161. }
  162. BtnDelete({ url: url }, row);
  163. } else {
  164. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  165. }
  166. }
  167. funs["btnCopy"] = function (url) {
  168. var row = $table.bootstrapTable("getSelections")[0];
  169. if (row) {
  170. MsgConfirm("确定拷贝【" + row.flowName + "-" + row.id + "】情景流吗?",
  171. "拷贝情景流", function () {
  172. $.iwbAjax1({
  173. url: url,
  174. table: "table",
  175. data: { id: row.id }
  176. });
  177. });
  178. } else {
  179. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  180. }
  181. };
  182. funs["btnSolidify"] = function (url) {
  183. var row = $table.bootstrapTable("getSelections")[0];
  184. if (row) {
  185. OpenModal({
  186. url: url,
  187. table: "table",
  188. modal: 'modal-solidify',
  189. data: { id: row.id, newName: row.flowName },
  190. dataFun: function () {
  191. return {
  192. id: $('#modal-solidify #id').val(),
  193. newName: $('#modal-solidify #newName').val()
  194. };
  195. }
  196. });
  197. } else {
  198. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  199. }
  200. };
  201. });
  202. function GetSaveData() {
  203. var data = $.formSerialize($('#form'));
  204. data.contentInfo = JSON.stringify(window._FlowTreeData);
  205. data.componentInfo = JSON.stringify(_CompData);
  206. return data;
  207. }
  208. function InitScTree() {
  209. $('#sc-tree')
  210. .jstree({
  211. 'core': {
  212. 'data': GetNode,
  213. 'strings': {
  214. 'Loading ...': '请稍后...'
  215. },
  216. 'force_text': true,
  217. 'check_callback': true,
  218. 'themes': {
  219. 'name': 'proton',
  220. 'responsive': true,
  221. 'variant': 'large'
  222. }
  223. },
  224. 'plugins': ['wholerow'] // 'state',
  225. }).on('ready.jstree',function(e, data) {
  226. //console.log('000', e, data);
  227. var inst = data.instance,
  228. obj = inst.get_node('@(IwbConsts.SceneCategoryRootNo)');
  229. inst.open_node(obj);
  230. inst.select_node(obj);
  231. cuScNo = '';
  232. RefreshTable();
  233. }).on('activate_node.jstree',function(e, data) {
  234. //console.log('111',data);
  235. cuScNo = data.node.id == '@(IwbConsts.SceneCategoryRootNo)' ? "" : data.node.id;
  236. RefreshTable();
  237. });
  238. }
  239. function GetNode(node, callback) {
  240. $.iwbAjax4({
  241. url: abp.appUrl + 'Query/GetChildSceneCategory',
  242. data: { id: node.id },
  243. success: function(res) {
  244. if (callback) {
  245. callback.call(this, res);
  246. } else {
  247. $("#sc-tree").html("暂无数据!");
  248. }
  249. }
  250. });
  251. }
  252. function TableSearchFun(sl) {
  253. sl.push({
  254. KeyWords: cuScNo,
  255. KeyField: 'sceneCategory',
  256. FieldType: '0',
  257. ExpType: '0'
  258. });
  259. }
  260. </script>
  261. <!--格式化-->
  262. <script id="formatter-script" type="text/javascript">
  263. function TypeFormatter(v) {
  264. var name = $('#hid-type option[value="' + v + '"]').text();
  265. switch (v) {
  266. case 0:
  267. return '<span class="label label-danger">' + name + '</span>';
  268. default:
  269. return '<span class="label label-info">' + name + '</span>';
  270. }
  271. }
  272. function FlowStateFormatter(v) {
  273. var name = $('#hid-flowState option[value="' + v + '"]').text();
  274. switch (v) {
  275. case @SceneFlowStateDefinition.New:
  276. return '<span class="label label-danger">' + name + '</span>';
  277. case @SceneFlowStateDefinition.Solidified:
  278. return '<span class="label label-success">' + name +'</span>';
  279. default:
  280. return '';
  281. }
  282. }
  283. function GuideTypeFormatter(v) {
  284. var name = $('#hid-guideType option[value="' + v + '"]').text();
  285. switch (v) {
  286. case 0:
  287. return '<span class="label label-danger">' + name + '</span>';
  288. default:
  289. return '<span class="label label-info">' + name + '</span>';
  290. }
  291. }
  292. </script>
  293. }
  294. <section style="display: none">
  295. <select id="hid-type">
  296. <option value=""></option>
  297. </select>
  298. <select id="hid-flowState">
  299. @(Html.Raw(flowState))
  300. </select>
  301. <select id="hid-guideType">
  302. @(Html.Raw(guideType))
  303. </select>
  304. @*@Html.DropDownList("hid-type", type)*@
  305. </section>
  306. @*
  307. <div class="main-box">
  308. <div class="floor-box">
  309. <div class="floor-node" style="width: 100%">
  310. <div class="node-box"></div>
  311. <div class="line-box">
  312. <div class="line-group">
  313. <div class="line" style="width: 100%"><div class="line-d"></div></div>
  314. </div>
  315. <div class="line-group">
  316. <div class="line-m" style="width: 25%;visibility: hidden; "></div>
  317. <div class="line-m" style="width: 50%;"></div>
  318. <div class="line-m" style="width: 25%;visibility: hidden;"></div>
  319. </div>
  320. <div class="line-group">
  321. <div class="line" style="width: 50%"><div class="line-d line-d-l"></div></div>
  322. <div class="line" style="width: 50%"><div class="line-d line-d-r"></div></div>
  323. </div>
  324. </div>
  325. <div class="floor-box ">
  326. <div class="floor-node" style="width: 50%">
  327. <div class="node-box"></div>
  328. <div class="line-box">
  329. <div class="line-group ">
  330. <div class="line" style="width: 100%"><div class="line-d"></div></div>
  331. </div>
  332. <div class="line-group">
  333. <div class="line-m" style="width: 25%;visibility: hidden; "></div>
  334. <div class="line-m" style="width: 50%;"></div>
  335. <div class="line-m" style="width: 25%;visibility: hidden;"></div>
  336. </div>
  337. <div class="line-group">
  338. <div class="line" style="width: 50%"><div class="line-d line-d-l"></div></div>
  339. <div class="line" style="width: 50%"><div class="line-d line-d-r"></div></div>
  340. </div>
  341. </div>
  342. <div class="floor-box ">
  343. <div class="floor-node" style="width: 50%">
  344. <div class="node-box"></div>
  345. </div>
  346. <div class="floor-node" style="width: 50%">
  347. <div class="node-box"></div>
  348. </div>
  349. </div>
  350. </div>
  351. <div class="floor-node" style="width: 50%">
  352. <div class="node-box"></div>
  353. </div>
  354. </div>
  355. </div>
  356. </div>
  357. </div>
  358. *@