hc_flwhCtrl.js 21 KB

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