MaterialSelModel.qml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. import com.InteractiveTask 1.0
  4. Item {
  5. id: materialselmodel
  6. x: 290
  7. y: 130
  8. width: 1600
  9. height: 920
  10. property bool listviewstat : false
  11. property int takebackCount : 0
  12. property int instructionCount : 0
  13. property int inspectionCount : 0
  14. property int replacementCount : 0
  15. property var mapCallbackPair;
  16. onVisibleChanged:
  17. {
  18. if (visible === true)
  19. {
  20. proThread.moveCursorTo(0, 0);
  21. mainScreen.changeModel_text("物资管理");
  22. // var taskType = InteractiveTask.TypeHttpGet_getIsMaterialsLoanExceptionPage;
  23. // interactiveCore.appendTask(taskType, "", get_number);
  24. // 调用http
  25. interactiveCore.appendTask(
  26. InteractiveTask.TypeHttpGet_getCabinetHomePage, "", ()=>{
  27. refresh_home();
  28. refresh_oper();
  29. });
  30. }
  31. }
  32. function refresh_home()
  33. {
  34. takebackCount = parseInt(pConfig.srarNumber);
  35. replacementCount = parseInt(pConfig.schangeNumber);
  36. inspectionCount = parseInt(pConfig.scheckNumber);
  37. materialListModel.clear();
  38. var typeId = pConfig.sbottomTypeId;
  39. var typeName = pConfig.sbottomTypeName;
  40. var typeIcon = pConfig.sbottomTypeIcon;
  41. var typeAll = pConfig.sbottomTypeAll;
  42. var typeBorrowable = pConfig.sbottomTypeBorrowable;
  43. for (var i = 0; i < typeId.length; ++i)
  44. {
  45. var key = typeId[i];
  46. var count = "(" +typeBorrowable[key] + "/" + typeAll[key] + ")"
  47. materialListModel.append({source: typeIcon[key], count: count});
  48. }
  49. }
  50. function refresh_oper()
  51. {
  52. function_listModel.clear();
  53. mapCallbackPair = {};
  54. // 打印所有权限
  55. console.log("所有权限:", interactiveData.permissions);
  56. console.log("检查权限 iscs:receive-return 是否存在:", interactiveData.permissions.indexOf("iscs:receive-return") !== -1);
  57. if (interactiveData.isHavePower("iscs:receive-return"))
  58. {
  59. mapCallbackPair["iscs:receive-return"] = function() {
  60. mainScreen.changeModel_text(takebacksel.text);
  61. materialSelmodel.visible = false;
  62. materialTakeBack.visible = true;
  63. }
  64. function_listModel.append(
  65. {
  66. icon: "qrc:/png/takeback.png",
  67. count: takebackCount,
  68. nameCn: qsTr("物资取还"),
  69. nameEn: qsTr("Materials Fetch And Return"),
  70. gradientColor0: "#4c237eff",
  71. gradientColor1: "#0099ff",
  72. gradientOrientation: Gradient.Horizontal,
  73. chickCallback: "iscs:receive-return",
  74. spacing: 150
  75. });
  76. }
  77. console.log("检查权限 iscs:Inspection-plan 是否存在:", interactiveData.permissions.indexOf("iscs:Inspection-plan") !== -1);
  78. if (interactiveData.isHavePower("iscs:Instructions"))
  79. {
  80. mapCallbackPair["iscs:Instructions"] = function() {
  81. mainScreen.changeModel_text(instructionsel.text);
  82. materialSelmodel.visible = false
  83. materialInstructions.visible = true
  84. }
  85. function_listModel.append(
  86. {
  87. icon: "qrc:/png/instructions.png",
  88. count: instructionCount,
  89. nameCn: qsTr("物资使用说明"),
  90. nameEn: qsTr("Materials Instructions"),
  91. gradientColor0: "#80fe2828",
  92. gradientColor1: "#ff7676",
  93. gradientOrientation: Gradient.Horizontal,
  94. chickCallback: "iscs:Instructions",
  95. spacing: 60
  96. });
  97. }
  98. console.log("检查权限 iscs:Inspection-plan 是否存在:", interactiveData.permissions.indexOf("iscs:Inspection-plan") !== -1);
  99. if (interactiveData.isHavePower("iscs:Inspection-plan"))
  100. {
  101. mapCallbackPair["iscs:Inspection-plan"] = function() {
  102. mainScreen.changeModel_text(inspectionsel.text);
  103. materialSelmodel.visible = false
  104. materialCheckPlan.visible = true
  105. }
  106. function_listModel.append(
  107. {
  108. icon: "qrc:/png/inspection.png",
  109. count: inspectionCount,
  110. nameCn: qsTr("物资检查"),
  111. nameEn: qsTr("Materials Check"),
  112. gradientColor0: "#8014b03e",
  113. gradientColor1: "#14b03e",
  114. gradientOrientation: Gradient.Horizontal,
  115. chickCallback: "iscs:Inspection-plan",
  116. spacing: 150
  117. });
  118. }
  119. console.log("检查权限 iscs:replacement 是否存在:", interactiveData.permissions.indexOf("iscs:replacement") !== -1);
  120. if (interactiveData.isHavePower("iscs:replacement"))
  121. {
  122. mapCallbackPair["iscs:replacement"] = function() {
  123. mainScreen.changeModel_text(replacementsel.text);
  124. materialSelmodel.visible = false
  125. materialReplace.visible = true
  126. }
  127. function_listModel.append(
  128. {
  129. icon: "qrc:/png/inspection.png",
  130. count: replacementCount,
  131. nameCn: qsTr("维修/更换"),
  132. nameEn: qsTr("Repair / Replacement"),
  133. gradientColor0: "#80c1cb17",
  134. gradientColor1: "#c1cb17",
  135. gradientOrientation: Gradient.Horizontal,
  136. chickCallback: "iscs:replacement",
  137. spacing: 150
  138. });
  139. }
  140. }
  141. ListModel {
  142. id: function_listModel
  143. }
  144. Rectangle {
  145. width: 1600
  146. height: 800
  147. color: "#272b7ae9"
  148. radius: 20 // 可选,设置圆角
  149. clip: true
  150. // visible: false
  151. GridView {
  152. anchors.fill: parent
  153. leftMargin: 100
  154. rightMargin: 100
  155. topMargin: 50
  156. bottomMargin: 50
  157. cellWidth: 700
  158. cellHeight: 350
  159. model: function_listModel
  160. delegate: Rectangle {
  161. width: 700
  162. height: 350
  163. color: "transparent"
  164. Button {
  165. anchors.centerIn: parent
  166. width: 600
  167. height: 300
  168. background: Rectangle {
  169. border.color: "#4c237eff"
  170. border.width: 2
  171. radius: 40
  172. gradient: Gradient {
  173. GradientStop {
  174. position: 0
  175. color: model.gradientColor0
  176. }
  177. GradientStop {
  178. position: 1
  179. color: model.gradientColor1
  180. }
  181. orientation: model.gradientOrientation
  182. }
  183. }
  184. icon.height: 200
  185. icon.width: 200
  186. display: AbstractButton.TextBesideIcon
  187. icon.source: model.icon
  188. text: model.nameCn
  189. font.pixelSize: 40
  190. spacing: model.spacing
  191. palette.buttonText: "white"
  192. activeFocusOnTab: false
  193. Rectangle {
  194. x: 500
  195. y: 30
  196. width: 60
  197. height: 60
  198. visible: (model.count > 0)
  199. radius: width / 2
  200. color: "#000000ff"
  201. border.color: "#ffffff"
  202. border.width: 3
  203. Text {
  204. x: 10
  205. y: 10
  206. width: 40
  207. height: 40
  208. text: model.count.toString()
  209. font.pixelSize: 30
  210. horizontalAlignment: Text.AlignHCenter
  211. verticalAlignment: Text.AlignVCenter
  212. color: "#ffffff"
  213. }
  214. }
  215. Text {
  216. x: 300
  217. y: 200
  218. width: 250
  219. text: model.nameEn
  220. font.pixelSize: 20
  221. color: "#ffffff"
  222. horizontalAlignment: Text.AlignRight
  223. }
  224. onClicked: {
  225. var key = model.chickCallback
  226. // 如果存在
  227. if (mapCallbackPair.hasOwnProperty(key))
  228. {
  229. // 进行回调函数校验
  230. if (typeof mapCallbackPair[key] === "function")
  231. {
  232. mapCallbackPair[key]();
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. Rectangle {
  241. id: materialModel
  242. visible: false
  243. width: 1600
  244. height: 810
  245. color: "#272b7ae9"
  246. radius: 20 // 可选,设置圆角
  247. Button {
  248. id: takebacksel
  249. x: 150
  250. y: 60
  251. width: 600
  252. height: 300
  253. background: Rectangle {
  254. id: password_sel_background
  255. border.color: "#4c237eff"
  256. border.width: 2
  257. gradient: Gradient {
  258. GradientStop {
  259. position: 0
  260. color: "#811ea5ff"
  261. }
  262. GradientStop {
  263. position: 1
  264. color: "#0099ff"
  265. }
  266. orientation: Gradient.Horizontal
  267. }
  268. // 边框宽度
  269. radius: 40 // 可选,设置圆角
  270. }
  271. icon.height: 200
  272. icon.width: 200
  273. display: AbstractButton.TextBesideIcon
  274. icon.source: "qrc:/png/takeback.png"
  275. text: qsTr("物资取还")
  276. font.pixelSize: 40
  277. spacing: 150
  278. palette.buttonText: "white" // 设置字体颜色为绿
  279. activeFocusOnTab: false
  280. Rectangle {
  281. x: 500
  282. y: 30
  283. width: 60
  284. height: 60
  285. visible: (takebackCount > 0)
  286. radius: width / 2 // 使矩形看起来像一个圆圈
  287. color: "#000000ff"
  288. border.color: "#ffffff"
  289. border.width: 3
  290. Text {
  291. x: 10
  292. y: 10
  293. width: 40
  294. height: 40
  295. text: qsTr(takebackCount.toString())
  296. font.pixelSize: 30
  297. horizontalAlignment: Text.AlignHCenter
  298. verticalAlignment: Text.AlignVCenter
  299. color: "#ffffff"
  300. }
  301. }
  302. Connections {
  303. target: takebacksel
  304. onClicked: {
  305. if (interactiveData.isHavePower("iscs:receive-return"))
  306. {
  307. mainScreen.changeModel_text(takebacksel.text);
  308. materialSelmodel.visible = false;
  309. materialTakeBack.visible = true;
  310. }
  311. else
  312. {
  313. infoPromptBox.title("提示");
  314. infoPromptBox.message("没有权限");
  315. infoPromptBox.button_clear();
  316. infoPromptBox.button_push("#3498db", "确定", null, null);
  317. infoPromptBox.show();
  318. }
  319. }
  320. }
  321. Text {
  322. x: 300
  323. y: 200
  324. text: qsTr("Materials Fetch And Return")
  325. font.pixelSize: 20
  326. color: "#ffffff"
  327. }
  328. }
  329. Button {
  330. id: instructionsel
  331. x: 850
  332. y: 60
  333. width: 600
  334. height: 300
  335. background: Rectangle {
  336. border.color: "#4ce92b2b"
  337. border.width: 2
  338. gradient: Gradient {
  339. GradientStop {
  340. position: 0
  341. color: "#80fe2828"
  342. }
  343. GradientStop {
  344. position: 1
  345. color: "#ff7676"
  346. }
  347. orientation: Gradient.Horizontal
  348. }
  349. // 边框宽度
  350. radius: 40 // 可选,设置圆角
  351. }
  352. icon.height: 200
  353. icon.width: 200
  354. display: AbstractButton.TextBesideIcon
  355. icon.source: "qrc:/png/instructions.png"
  356. text: qsTr("物资使用说明")
  357. font.pixelSize: 40
  358. spacing: 80
  359. palette.buttonText: "white" // 设置字体颜色为绿
  360. activeFocusOnTab: false
  361. Rectangle {
  362. x: 500
  363. y: 30
  364. width: 60
  365. height: 60
  366. visible: (instructionCount > 0)
  367. radius: width / 2 // 使矩形看起来像一个圆圈
  368. color: "#000000ff"
  369. border.color: "#ffffff"
  370. border.width: 3
  371. Text {
  372. x: 10
  373. y: 10
  374. width: 40
  375. height: 40
  376. text: qsTr(instructionCount.toString())
  377. font.pixelSize: 30
  378. horizontalAlignment: Text.AlignHCenter
  379. verticalAlignment: Text.AlignVCenter
  380. color: "#ffffff"
  381. }
  382. }
  383. Connections {
  384. target: instructionsel
  385. onClicked: {
  386. if (interactiveData.isHavePower("iscs:Instructions"))
  387. {
  388. mainScreen.changeModel_text(instructionsel.text);
  389. materialSelmodel.visible = false
  390. materialInstructions.visible = true
  391. }
  392. else
  393. {
  394. infoPromptBox.title("提示");
  395. infoPromptBox.message("没有权限");
  396. infoPromptBox.button_clear();
  397. infoPromptBox.button_push("#3498db", "确定", null, null);
  398. infoPromptBox.show();
  399. }
  400. }
  401. }
  402. Text {
  403. x: 360
  404. y: 200
  405. text: qsTr("Materials Instructions")
  406. font.pixelSize: 20
  407. color: "#ffffff"
  408. }
  409. }
  410. Button {
  411. id: inspectionsel
  412. x: 150
  413. y: 440
  414. width: 600
  415. height: 300
  416. background: Rectangle {
  417. border.color: "#4c14b03e"
  418. border.width: 2
  419. gradient: Gradient {
  420. GradientStop {
  421. position: 0
  422. color: "#8014b03e"
  423. }
  424. GradientStop {
  425. position: 1
  426. color: "#14b03e"
  427. }
  428. orientation: Gradient.Horizontal
  429. }
  430. // 边框宽度
  431. radius: 40 // 可选,设置圆角
  432. }
  433. icon.height: 200
  434. icon.width: 200
  435. display: AbstractButton.TextBesideIcon
  436. icon.source: "qrc:/png/inspection.png"
  437. text: qsTr("物资检查")
  438. font.pixelSize: 40
  439. spacing: 150
  440. palette.buttonText: "white" // 设置字体颜色为绿
  441. activeFocusOnTab: false
  442. Rectangle {
  443. x: 500
  444. y: 30
  445. width: 60
  446. height: 60
  447. visible: (inspectionCount > 0)
  448. radius: width / 2 // 使矩形看起来像一个圆圈
  449. color: "#000000ff"
  450. border.color: "#ffffff"
  451. border.width: 3
  452. Text {
  453. x: 10
  454. y: 10
  455. width: 40
  456. height: 40
  457. text: qsTr(inspectionCount.toString())
  458. font.pixelSize: 30
  459. horizontalAlignment: Text.AlignHCenter
  460. verticalAlignment: Text.AlignVCenter
  461. color: "#ffffff"
  462. }
  463. }
  464. Connections {
  465. target: inspectionsel
  466. onClicked: {
  467. if (interactiveData.isHavePower("iscs:Inspection-plan"))
  468. {
  469. mainScreen.changeModel_text(inspectionsel.text);
  470. materialSelmodel.visible = false
  471. materialCheckPlan.visible = true
  472. }
  473. else
  474. {
  475. infoPromptBox.title("提示");
  476. infoPromptBox.message("没有权限");
  477. infoPromptBox.button_clear();
  478. infoPromptBox.button_push("#3498db", "确定", null, null);
  479. infoPromptBox.show();
  480. }
  481. }
  482. }
  483. Text {
  484. x: 360
  485. y: 200
  486. text: qsTr("Materials Inspection")
  487. font.pixelSize: 20
  488. color: "#ffffff"
  489. }
  490. }
  491. Button {
  492. id: replacementsel
  493. x: 850
  494. y: 440
  495. width: 600
  496. height: 300
  497. background: Rectangle {
  498. border.color: "#4cc1cb17"
  499. border.width: 2
  500. gradient: Gradient {
  501. GradientStop {
  502. position: 0
  503. color: "#80c1cb17"
  504. }
  505. GradientStop {
  506. position: 1
  507. color: "#c1cb17"
  508. }
  509. orientation: Gradient.Horizontal
  510. }
  511. // 边框宽度
  512. radius: 40 // 可选,设置圆角
  513. }
  514. icon.height: 200
  515. icon.width: 200
  516. display: AbstractButton.TextBesideIcon
  517. icon.source: "qrc:/png/replacement.png"
  518. text: qsTr("维修/更换")
  519. font.pixelSize: 40
  520. spacing: 150
  521. palette.buttonText: "white" // 设置字体颜色为绿
  522. activeFocusOnTab: false
  523. Rectangle {
  524. x: 500
  525. y: 30
  526. width: 60
  527. height: 60
  528. visible: (replacementCount > 0)
  529. radius: width / 2 // 使矩形看起来像一个圆圈
  530. color: "#000000ff"
  531. border.color: "#ffffff"
  532. border.width: 3
  533. Text {
  534. x: 10
  535. y: 10
  536. width: 40
  537. height: 40
  538. text: qsTr(replacementCount.toString())
  539. font.pixelSize: 30
  540. horizontalAlignment: Text.AlignHCenter
  541. verticalAlignment: Text.AlignVCenter
  542. color: "#ffffff"
  543. }
  544. }
  545. Connections {
  546. target: replacementsel
  547. onClicked: {
  548. if (interactiveData.isHavePower("iscs:replacement"))
  549. {
  550. mainScreen.changeModel_text(replacementsel.text);
  551. materialSelmodel.visible = false
  552. materialReplace.visible = true
  553. }
  554. else
  555. {
  556. infoPromptBox.title("提示");
  557. infoPromptBox.message("没有权限");
  558. infoPromptBox.button_clear();
  559. infoPromptBox.button_push("#3498db", "确定", null, null);
  560. infoPromptBox.show();
  561. }
  562. }
  563. }
  564. Text {
  565. x: 340
  566. y: 200
  567. text: qsTr("Materials Replacement")
  568. font.pixelSize: 20
  569. color: "#ffffff"
  570. }
  571. }
  572. }
  573. Rectangle {
  574. id: materialviewrectangle
  575. x: 0
  576. y: 820
  577. width: 1600
  578. height: 100
  579. color: "#742b7ae9"
  580. radius: 20
  581. clip: true
  582. Text {
  583. x: 31
  584. y: 31
  585. text: qsTr("物资数量(可借/总数):")
  586. font.pixelSize: 30
  587. color: "#ffffff"
  588. } // 可选,设置圆角
  589. ListModel {
  590. id: materialListModel
  591. }
  592. Rectangle {
  593. id: materialInfo
  594. x: 340
  595. y: 25
  596. width: 1100
  597. height: 50
  598. color: "#002b7ae9"
  599. Grid {
  600. x: 50
  601. y: 0
  602. width: parent.width -50
  603. height: parent.height
  604. visible: true
  605. columns: 5
  606. spacing: 50
  607. Repeater {
  608. id: instantiator
  609. model: materialListModel
  610. delegate: Rectangle{
  611. width: 150
  612. height: 50
  613. color: "#00ffffff"
  614. Image {
  615. x: 0
  616. y: 0
  617. width: 50
  618. height: 50
  619. visible: true
  620. source: model.source
  621. fillMode: Image.PreserveAspectFit
  622. }
  623. Text {
  624. x: 50
  625. y: 0
  626. width: 100
  627. height: 50
  628. visible: true
  629. text: model.count
  630. font.pixelSize: 30
  631. horizontalAlignment: Text.AlignHCenter
  632. verticalAlignment: Text.AlignVCenter
  633. color: "#ffffff"
  634. }
  635. }
  636. }
  637. }
  638. }
  639. Image {
  640. id: viewImage
  641. x: 1507
  642. y: 15
  643. width: 70
  644. height: 70
  645. source: "qrc:/png/right.png"
  646. fillMode: Image.PreserveAspectFit
  647. MouseArea {
  648. anchors.fill: parent // 让MouseArea覆盖整个Image区域
  649. onClicked: {
  650. viewListAll()
  651. }
  652. }
  653. }
  654. }
  655. function viewListAll()
  656. {
  657. if(listviewstat == false)
  658. {
  659. listviewstat = true;
  660. viewImage.rotation = 90;
  661. materialviewrectangle.height = materialviewrectangle.height + 500
  662. materialviewrectangle.y = materialviewrectangle.y - 500;
  663. }
  664. else{
  665. listviewstat = false;
  666. viewImage.rotation = 0;
  667. materialviewrectangle.height = materialviewrectangle.height - 500
  668. materialviewrectangle.y = materialviewrectangle.y + 500;
  669. }
  670. }
  671. Component.onCompleted: {
  672. }
  673. function slot_updateMaterial()
  674. {
  675. // materialListModel.clear();
  676. // var typeborrowablenumber = pConfig.smaterialTypeBorrowableNumberList;
  677. // var typecount = pConfig.smaterialTypeCountList;
  678. // var typepng = pConfig.smaterialTypePngList;
  679. // for (var key in typecount)
  680. // {
  681. // console.log("Key:", key, "Value:", data[key]);
  682. // var number = "(" +typeborrowablenumber[key] + "/" + typecount[key] + ")"
  683. // materialListModel.append({source: typepng[key], count: number});
  684. // }
  685. }
  686. }