hc_flwhCtrl.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. app.controller('hc_flwhCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_user_data", "api_wechatfile", function ($rootScope, $scope, $http, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_user_data, api_wechatfile) {
  2. $scope.langs = i18nService.getAllLangs();
  3. $scope.lang = 'zh-cn';
  4. $scope.name_shuzu = [];
  5. $scope.pinpai_shuzu = [];
  6. $scope.guige_shuzu = [];
  7. $scope.name_show = false;
  8. $scope.pinpai_show = false;
  9. $scope.guige_show = false;
  10. //耗材名称编辑
  11. $scope.name_edit = function () {
  12. $scope.name_show = true;
  13. }
  14. // 名称取消
  15. $scope.name_quxiao = function () {
  16. $scope.name_show = false;
  17. }
  18. // 耗材名称分类
  19. $scope.refreshDat_name = function () {
  20. var dat = {
  21. idx: 0,
  22. sum: 999,
  23. dictionaryTree: {
  24. "key": "haocaifenlei",
  25. deleted: 0
  26. }
  27. }
  28. api_user_data.fetchDataList('dictionaryTree', dat).then(function (data) {
  29. if(data.status == 200){
  30. $scope.names = data.list;
  31. }
  32. });
  33. };
  34. //点击耗材名称,查询品牌型号和规格
  35. $scope.clickname = function (res, index) {
  36. $scope.index = index;
  37. if (res.id != '' && res.id != undefined) {
  38. $scope.panduan = "修改";
  39. $scope.tit = res.name;
  40. $scope.ids = res.id;
  41. //品牌型号
  42. var dat = {
  43. idx: 0,
  44. sum: 999,
  45. dictionaryTree: {
  46. "key": "pinpai",
  47. "parent": res.id
  48. }
  49. }
  50. api_user_data.fetchDataList('dictionaryTree', dat).then(function (data) {
  51. if(data.status == 200){
  52. $scope.xinghaos = data.list;
  53. }
  54. });
  55. //规格
  56. var dat1 = {
  57. idx: 0,
  58. sum: 999,
  59. dictionaryTree: {
  60. "key": "guige",
  61. "parent": res.id
  62. }
  63. }
  64. api_user_data.fetchDataList('dictionaryTree', dat1).then(function (data) {
  65. if(data.status == 200){
  66. $scope.guiges = data.list;
  67. }
  68. });
  69. } else {
  70. $scope.panduan = "新增";
  71. $scope.tit = '';
  72. $scope.ids = ''
  73. }
  74. }
  75. //名称新增按钮
  76. $scope.add_name = function () {
  77. $scope.names.unshift({ name: "添加名称" });
  78. }
  79. //型号新增按钮
  80. $scope.add_xinghao = function () {
  81. if ($scope.tit == '' || $scope.tit == undefined) {
  82. SweetAlert.swal({
  83. title: "新增失败",
  84. text: "请先选择名称!",
  85. type: "error"
  86. });
  87. } else {
  88. $scope.xinghaos.unshift({ name: "添加型号" })
  89. }
  90. }
  91. // 规格新增按钮
  92. $scope.add_guige = function () {
  93. if ($scope.tit == '' || $scope.tit == undefined) {
  94. SweetAlert.swal({
  95. title: "新增失败",
  96. text: "请先选择名称!",
  97. type: "error"
  98. });
  99. } else {
  100. $scope.guiges.unshift({ name: "添加规格" })
  101. }
  102. }
  103. //名称编辑完成
  104. $scope.name_wancheng = function (res) {
  105. for (var k = 0; k < $scope.names.length; k++) {
  106. $scope.name_shuzu.push($scope.names[k].name)
  107. }
  108. if ($scope.ids != '' && $scope.ids != undefined) {
  109. if ($scope.name_ipt[res] == '' || $scope.name_ipt[res] == undefined) {
  110. SweetAlert.swal({
  111. title: "修改失败",
  112. text: "修改值不能为空!",
  113. type: "error"
  114. });
  115. } else {
  116. if ($scope.name_shuzu.indexOf($scope.name_ipt[res]) !== -1) {
  117. SweetAlert.swal({
  118. title: "修改失败",
  119. text: "修改值已存在!",
  120. type: "error"
  121. });
  122. } else {
  123. var dat1 = {
  124. dictionaryTree: {
  125. id: $scope.ids,
  126. key: "haocaifenlei",
  127. name: $scope.name_ipt[res],
  128. value: $scope.name_ipt[res],
  129. level: 1,
  130. system: 0,
  131. deleted: 0
  132. }
  133. }
  134. api_user_data.addData('dictionaryTree',dat1).then(function (data) {
  135. $scope.name_show = false;
  136. $scope.name_shuzu = [];
  137. SweetAlert.swal({
  138. title: "修改成功",
  139. confirmButtonColor: "#007AFF",
  140. type: "success"
  141. });
  142. $scope.refreshDat_name();
  143. });
  144. }
  145. }
  146. } else {
  147. if ($scope.name_ipt[res] == '' || $scope.name_ipt[res] == undefined) {
  148. SweetAlert.swal({
  149. title: "新增失败",
  150. text: "新增值不能为空!",
  151. type: "error"
  152. });
  153. } else {
  154. if ($scope.name_shuzu.indexOf($scope.name_ipt[res]) !== -1) {
  155. SweetAlert.swal({
  156. title: "新增失败",
  157. text: "新增值已存在!",
  158. type: "error"
  159. });
  160. } else {
  161. var dat = {
  162. dictionaryTree: {
  163. key: "haocaifenlei",
  164. name: $scope.name_ipt[res],
  165. value: $scope.name_ipt[res],
  166. level: 1,
  167. system: 0,
  168. deleted: 0
  169. }
  170. }
  171. api_user_data.addData('dictionaryTree', dat).then(function (data) {
  172. $scope.name_show = false;
  173. $scope.name_shuzu = [];
  174. SweetAlert.swal({
  175. title: "新增成功",
  176. confirmButtonColor: "#007AFF",
  177. type: "success"
  178. });
  179. $scope.refreshDat_name();
  180. });
  181. }
  182. }
  183. }
  184. }
  185. // 名称删除
  186. $scope.name_del = function (res) {
  187. if(!res.id){
  188. $scope.refreshDat_name();
  189. $scope.tit = '';
  190. $scope.ids = '';
  191. return;
  192. }
  193. SweetAlert.swal({
  194. title: "确认删除?",
  195. text: "删除的数据不可恢复,请确认继续操作!",
  196. type: "warning",
  197. showCancelButton: true,
  198. confirmButtonColor: "#DD6B55",
  199. confirmButtonText: "继续删除",
  200. cancelButtonText: "取消操作",
  201. closeOnConfirm: false,
  202. closeOnCancel: false
  203. }, function (isConfirm) {
  204. if (isConfirm) {
  205. var dat1 = [Number(res.id)]
  206. api_user_data.rmvData('dictionaryTree',dat1).then(function (data) {
  207. $scope.refreshDat_name();
  208. $scope.tit = '';
  209. $scope.ids = '';
  210. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  211. });
  212. } else {
  213. SweetAlert.swal("操作取消", "数据安全", "error");
  214. }
  215. });
  216. }
  217. //品牌编辑
  218. $scope.pinpai_edit = function (res, index) {
  219. $scope.pinpai_index = index;
  220. if (res.id != '' && res.id != undefined) {
  221. $scope.pinpai_panduan = "修改";
  222. $scope.pinpai_ids = res.id;
  223. } else {
  224. $scope.pinpai_panduan = "新增";
  225. $scope.pinpai_ids = '';
  226. }
  227. $scope.pinpai_show = true;
  228. }
  229. // 品牌取消
  230. $scope.pinpai_quxiao = function () {
  231. $scope.pinpai_show = false;
  232. }
  233. //品牌完成
  234. $scope.pinpai_wancheng = function (res) {
  235. for (var k = 0; k < $scope.xinghaos.length; k++) {
  236. $scope.pinpai_shuzu.push($scope.xinghaos[k].name)
  237. }
  238. if ($scope.pinpai_ids != '' && $scope.pinpai_ids != undefined) {
  239. if ($scope.pinpai_ipt[res] == '' || $scope.pinpai_ipt[res] == undefined) {
  240. SweetAlert.swal({
  241. title: "修改失败",
  242. text: "修改值不能为空!",
  243. type: "error"
  244. });
  245. } else {
  246. if ($scope.pinpai_shuzu.indexOf($scope.pinpai_ipt[res]) !== -1) {
  247. SweetAlert.swal({
  248. title: "修改失败",
  249. text: "修改值已存在!",
  250. type: "error"
  251. });
  252. } else {
  253. var dat1 = {
  254. dictionaryTree: {
  255. id: $scope.pinpai_ids,
  256. key: "pinpai",
  257. name: $scope.pinpai_ipt[res],
  258. value: $scope.pinpai_ipt[res],
  259. level: 1,
  260. system: 0,
  261. deleted: 0
  262. }
  263. }
  264. api_user_data.addData('dictionaryTree',dat1).then(function (data) {
  265. $scope.pinpai_show = false;
  266. $scope.pinpai_shuzu = [];
  267. SweetAlert.swal({
  268. title: "修改成功",
  269. confirmButtonColor: "#007AFF",
  270. type: "success"
  271. });
  272. //品牌型号
  273. var dat2 = {
  274. idx: 0,
  275. sum: 999,
  276. dictionaryTree: {
  277. "key": "pinpai",
  278. "parent": $scope.ids
  279. }
  280. }
  281. api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
  282. if(data.status == 200){
  283. $scope.xinghaos = data.list;
  284. }
  285. });
  286. });
  287. }
  288. }
  289. } else {
  290. if ($scope.pinpai_ipt[res] == '' || $scope.pinpai_ipt[res] == undefined) {
  291. SweetAlert.swal({
  292. title: "新增失败",
  293. text: "新增值不能为空!",
  294. type: "error"
  295. });
  296. } else {
  297. if ($scope.pinpai_shuzu.indexOf($scope.pinpai_ipt[res]) !== -1) {
  298. SweetAlert.swal({
  299. title: "新增失败",
  300. text: "新增值已存在!",
  301. type: "error"
  302. });
  303. } else {
  304. var dat = {
  305. dictionaryTree: {
  306. key: "pinpai",
  307. name: $scope.pinpai_ipt[res],
  308. value: $scope.pinpai_ipt[res],
  309. level: 1,
  310. system: 0,
  311. deleted: 0,
  312. parent: $scope.ids
  313. }
  314. }
  315. api_user_data.addData('dictionaryTree', dat).then(function (data) {
  316. $scope.pinpai_show = false;
  317. $scope.pinpai_shuzu = [];
  318. SweetAlert.swal({
  319. title: "新增成功",
  320. confirmButtonColor: "#007AFF",
  321. type: "success"
  322. });
  323. //品牌型号
  324. var dat1 = {
  325. idx: 0,
  326. sum: 999,
  327. dictionaryTree: {
  328. "key": "pinpai",
  329. "parent": $scope.ids
  330. }
  331. }
  332. api_user_data.fetchDataList('dictionaryTree', dat1).then(function (data) {
  333. if(data.status == 200){
  334. $scope.xinghaos = data.list;
  335. }
  336. });
  337. });
  338. }
  339. }
  340. }
  341. }
  342. //品牌删除
  343. $scope.pinpai_del = function (res) {
  344. if(!res.id){
  345. $scope.pinpai_show = false;
  346. //品牌型号
  347. var dat2 = {
  348. idx: 0,
  349. sum: 999,
  350. dictionaryTree: {
  351. "key": "pinpai",
  352. "parent": $scope.ids
  353. }
  354. }
  355. api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
  356. if(data.status == 200){
  357. $scope.xinghaos = data.list;
  358. }
  359. });
  360. return;
  361. }
  362. SweetAlert.swal({
  363. title: "确认删除?",
  364. text: "删除的数据不可恢复,请确认继续操作!",
  365. type: "warning",
  366. showCancelButton: true,
  367. confirmButtonColor: "#DD6B55",
  368. confirmButtonText: "继续删除",
  369. cancelButtonText: "取消操作",
  370. closeOnConfirm: false,
  371. closeOnCancel: false
  372. }, function (isConfirm) {
  373. if (isConfirm) {
  374. var dat1 = [Number(res.id)]
  375. api_user_data.rmvData('dictionaryTree',dat1).then(function (data) {
  376. $scope.pinpai_show = false;
  377. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  378. //品牌型号
  379. var dat2 = {
  380. idx: 0,
  381. sum: 999,
  382. dictionaryTree: {
  383. "key": "pinpai",
  384. "parent": $scope.ids
  385. }
  386. }
  387. api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
  388. if(data.status == 200){
  389. $scope.xinghaos = data.list;
  390. }
  391. });
  392. });
  393. } else {
  394. SweetAlert.swal("操作取消", "数据安全", "error");
  395. }
  396. });
  397. }
  398. // 规格编辑
  399. $scope.guige_edit = function (res, index) {
  400. $scope.guige_index = index;
  401. if (res.id != '' && res.id != undefined) {
  402. $scope.guige_panduan = "修改";
  403. $scope.guige_ids = res.id;
  404. } else {
  405. $scope.guige_panduan = "新增";
  406. $scope.guige_ids = '';
  407. }
  408. $scope.guige_show = true;
  409. }
  410. // 规格取消
  411. $scope.guige_quxiao = function () {
  412. $scope.guige_show = false;
  413. }
  414. //规格完成
  415. $scope.guige_wancheng = function (res) {
  416. for (var k = 0; k < $scope.guiges.length; k++) {
  417. $scope.guige_shuzu.push($scope.guiges[k].name)
  418. }
  419. if ($scope.guige_ids != '' && $scope.guige_ids != undefined) {
  420. if ($scope.guige_ipt[res] == '' || $scope.guige_ipt[res] == undefined) {
  421. SweetAlert.swal({
  422. title: "修改失败",
  423. text: "修改值不能为空!",
  424. type: "error"
  425. });
  426. } else {
  427. if ($scope.guige_shuzu.indexOf($scope.guige_ipt[res]) !== -1) {
  428. SweetAlert.swal({
  429. title: "修改失败",
  430. text: "修改值已存在!",
  431. type: "error"
  432. });
  433. } else {
  434. var dat1 = {
  435. dictionaryTree: {
  436. id: $scope.guige_ids,
  437. key: "guige",
  438. name: $scope.guige_ipt[res],
  439. value: $scope.guige_ipt[res],
  440. level: 1,
  441. system: 0,
  442. deleted: 0
  443. }
  444. }
  445. api_user_data.addData('dictionaryTree',dat1).then(function (data) {
  446. $scope.guige_show = false;
  447. $scope.guige_shuzu = [];
  448. SweetAlert.swal({
  449. title: "修改成功",
  450. confirmButtonColor: "#007AFF",
  451. type: "success"
  452. });
  453. //品牌型号
  454. var dat2 = {
  455. idx: 0,
  456. sum: 999,
  457. dictionaryTree: {
  458. "key": "guige",
  459. "parent": $scope.ids
  460. }
  461. }
  462. api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
  463. if(data.status == 200){
  464. $scope.guiges = data.list;
  465. }
  466. });
  467. });
  468. }
  469. }
  470. } else {
  471. if ($scope.guige_ipt[res] == '' || $scope.guige_ipt[res] == undefined) {
  472. SweetAlert.swal({
  473. title: "新增失败",
  474. text: "新增值不能为空!",
  475. type: "error"
  476. });
  477. } else {
  478. if ($scope.guige_shuzu.indexOf($scope.guige_ipt[res]) !== -1) {
  479. SweetAlert.swal({
  480. title: "新增失败",
  481. text: "新增值已存在!",
  482. type: "error"
  483. });
  484. } else {
  485. var dat = {
  486. dictionaryTree: {
  487. key: "guige",
  488. name: $scope.guige_ipt[res],
  489. value: $scope.guige_ipt[res],
  490. level: 1,
  491. system: 0,
  492. deleted: 0,
  493. parent: $scope.ids
  494. }
  495. }
  496. api_user_data.addData('dictionaryTree', dat).then(function (data) {
  497. $scope.guige_show = false;
  498. $scope.guige_shuzu = [];
  499. SweetAlert.swal({
  500. title: "新增成功",
  501. confirmButtonColor: "#007AFF",
  502. type: "success"
  503. });
  504. //品牌型号
  505. var dat1 = {
  506. idx: 0,
  507. sum: 999,
  508. dictionaryTree: {
  509. "key": "guige",
  510. "parent": $scope.ids
  511. }
  512. }
  513. api_user_data.fetchDataList('dictionaryTree', dat1).then(function (data) {
  514. if(data.status == 200){
  515. $scope.guiges = data.list;
  516. }
  517. });
  518. });
  519. }
  520. }
  521. }
  522. }
  523. //规格删除
  524. $scope.guige_del = function (res) {
  525. if(!res.id){
  526. $scope.guige_show = false;
  527. //品牌型号
  528. var dat2 = {
  529. idx: 0,
  530. sum: 999,
  531. dictionaryTree: {
  532. "key": "guige",
  533. "parent": $scope.ids
  534. }
  535. }
  536. api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
  537. if(data.status == 200){
  538. if(data.status == 200){
  539. $scope.guiges = data.list;
  540. }
  541. }
  542. });
  543. return;
  544. }
  545. SweetAlert.swal({
  546. title: "确认删除?",
  547. text: "删除的数据不可恢复,请确认继续操作!",
  548. type: "warning",
  549. showCancelButton: true,
  550. confirmButtonColor: "#DD6B55",
  551. confirmButtonText: "继续删除",
  552. cancelButtonText: "取消操作",
  553. closeOnConfirm: false,
  554. closeOnCancel: false
  555. }, function (isConfirm) {
  556. if (isConfirm) {
  557. var dat1 = [Number(res.id)]
  558. api_user_data.rmvData('dictionaryTree',dat1).then(function (data) {
  559. $scope.guige_show = false;
  560. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  561. //品牌型号
  562. var dat2 = {
  563. idx: 0,
  564. sum: 999,
  565. dictionaryTree: {
  566. "key": "guige",
  567. "parent": $scope.ids
  568. }
  569. }
  570. api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
  571. if(data.status == 200){
  572. $scope.guiges = data.list;
  573. }
  574. });
  575. });
  576. } else {
  577. SweetAlert.swal("操作取消", "数据安全", "error");
  578. }
  579. });
  580. }
  581. $scope.refreshDat_name();
  582. }]);