hc_flwhCtrl.js 21 KB

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