123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 |
- 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) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- $scope.name_shuzu = [];
- $scope.pinpai_shuzu = [];
- $scope.guige_shuzu = [];
- $scope.name_show = false;
- $scope.pinpai_show = false;
- $scope.guige_show = false;
- //耗材名称编辑
- $scope.name_edit = function () {
- $scope.name_show = true;
- }
- // 名称取消
- $scope.name_quxiao = function () {
- $scope.name_show = false;
- }
- // 耗材名称分类
- $scope.refreshDat_name = function () {
- var dat = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "haocaifenlei",
- deleted: 0
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat).then(function (data) {
- if(data.status == 200){
- $scope.names = data.list;
- }
- });
- };
- //点击耗材名称,查询品牌型号和规格
- $scope.clickname = function (res, index) {
- $scope.index = index;
- if (res.id != '' && res.id != undefined) {
- $scope.panduan = "修改";
- $scope.tit = res.name;
- $scope.ids = res.id;
- //品牌型号
- var dat = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "pinpai",
- "parent": res.id
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat).then(function (data) {
- if(data.status == 200){
- $scope.xinghaos = data.list;
- }
- });
- //规格
- var dat1 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "guige",
- "parent": res.id
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat1).then(function (data) {
- if(data.status == 200){
- $scope.guiges = data.list;
- }
- });
- } else {
- $scope.panduan = "新增";
- $scope.tit = '';
- $scope.ids = ''
- }
- }
- //名称新增按钮
- $scope.add_name = function () {
- $scope.names.unshift({ name: "添加名称" });
- }
- //型号新增按钮
- $scope.add_xinghao = function () {
- if ($scope.tit == '' || $scope.tit == undefined) {
- SweetAlert.swal({
- title: "新增失败",
- text: "请先选择名称!",
- type: "error"
- });
- } else {
- $scope.xinghaos.unshift({ name: "添加型号" })
- }
- }
- // 规格新增按钮
- $scope.add_guige = function () {
- if ($scope.tit == '' || $scope.tit == undefined) {
- SweetAlert.swal({
- title: "新增失败",
- text: "请先选择名称!",
- type: "error"
- });
- } else {
- $scope.guiges.unshift({ name: "添加规格" })
- }
- }
- //名称编辑完成
- $scope.name_wancheng = function (res) {
- for (var k = 0; k < $scope.names.length; k++) {
- $scope.name_shuzu.push($scope.names[k].name)
- }
- if ($scope.ids != '' && $scope.ids != undefined) {
- if ($scope.name_ipt[res] == '' || $scope.name_ipt[res] == undefined) {
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值不能为空!",
- type: "error"
- });
- } else {
- if ($scope.name_shuzu.indexOf($scope.name_ipt[res]) !== -1) {
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值已存在!",
- type: "error"
- });
- } else {
- var dat1 = {
- dictionaryTree: {
- id: $scope.ids,
- key: "haocaifenlei",
- name: $scope.name_ipt[res],
- value: $scope.name_ipt[res],
- level: 1,
- system: 0,
- deleted: 0
- }
- }
- api_user_data.addData('dictionaryTree',dat1).then(function (data) {
- $scope.name_show = false;
- $scope.name_shuzu = [];
- SweetAlert.swal({
- title: "修改成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $scope.refreshDat_name();
- });
- }
- }
- } else {
- if ($scope.name_ipt[res] == '' || $scope.name_ipt[res] == undefined) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值不能为空!",
- type: "error"
- });
- } else {
- if ($scope.name_shuzu.indexOf($scope.name_ipt[res]) !== -1) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值已存在!",
- type: "error"
- });
- } else {
- var dat = {
- dictionaryTree: {
- key: "haocaifenlei",
- name: $scope.name_ipt[res],
- value: $scope.name_ipt[res],
- level: 1,
- system: 0,
- deleted: 0
- }
- }
- api_user_data.addData('dictionaryTree', dat).then(function (data) {
- $scope.name_show = false;
- $scope.name_shuzu = [];
- SweetAlert.swal({
- title: "新增成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $scope.refreshDat_name();
- });
- }
- }
- }
- }
- // 名称删除
- $scope.name_del = function (res) {
- if(!res.id){
- $scope.refreshDat_name();
- $scope.tit = '';
- $scope.ids = '';
- return;
- }
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var dat1 = [Number(res.id)]
- api_user_data.rmvData('dictionaryTree',dat1).then(function (data) {
- $scope.refreshDat_name();
- $scope.tit = '';
- $scope.ids = '';
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- //品牌编辑
- $scope.pinpai_edit = function (res, index) {
- $scope.pinpai_index = index;
- if (res.id != '' && res.id != undefined) {
- $scope.pinpai_panduan = "修改";
- $scope.pinpai_ids = res.id;
- } else {
- $scope.pinpai_panduan = "新增";
- $scope.pinpai_ids = '';
- }
- $scope.pinpai_show = true;
- }
- // 品牌取消
- $scope.pinpai_quxiao = function () {
- $scope.pinpai_show = false;
- }
- //品牌完成
- $scope.pinpai_wancheng = function (res) {
- for (var k = 0; k < $scope.xinghaos.length; k++) {
- $scope.pinpai_shuzu.push($scope.xinghaos[k].name)
- }
- if ($scope.pinpai_ids != '' && $scope.pinpai_ids != undefined) {
- if ($scope.pinpai_ipt[res] == '' || $scope.pinpai_ipt[res] == undefined) {
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值不能为空!",
- type: "error"
- });
- } else {
- if ($scope.pinpai_shuzu.indexOf($scope.pinpai_ipt[res]) !== -1) {
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值已存在!",
- type: "error"
- });
- } else {
- var dat1 = {
- dictionaryTree: {
- id: $scope.pinpai_ids,
- key: "pinpai",
- name: $scope.pinpai_ipt[res],
- value: $scope.pinpai_ipt[res],
- level: 1,
- system: 0,
- deleted: 0
- }
- }
- api_user_data.addData('dictionaryTree',dat1).then(function (data) {
- $scope.pinpai_show = false;
- $scope.pinpai_shuzu = [];
- SweetAlert.swal({
- title: "修改成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- //品牌型号
- var dat2 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "pinpai",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
- if(data.status == 200){
- $scope.xinghaos = data.list;
- }
- });
- });
- }
- }
- } else {
- if ($scope.pinpai_ipt[res] == '' || $scope.pinpai_ipt[res] == undefined) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值不能为空!",
- type: "error"
- });
- } else {
- if ($scope.pinpai_shuzu.indexOf($scope.pinpai_ipt[res]) !== -1) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值已存在!",
- type: "error"
- });
- } else {
- var dat = {
- dictionaryTree: {
- key: "pinpai",
- name: $scope.pinpai_ipt[res],
- value: $scope.pinpai_ipt[res],
- level: 1,
- system: 0,
- deleted: 0,
- parent: $scope.ids
- }
- }
- api_user_data.addData('dictionaryTree', dat).then(function (data) {
- $scope.pinpai_show = false;
- $scope.pinpai_shuzu = [];
- SweetAlert.swal({
- title: "新增成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- //品牌型号
- var dat1 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "pinpai",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat1).then(function (data) {
- if(data.status == 200){
- $scope.xinghaos = data.list;
- }
- });
- });
- }
- }
- }
- }
- //品牌删除
- $scope.pinpai_del = function (res) {
- if(!res.id){
- $scope.pinpai_show = false;
- //品牌型号
- var dat2 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "pinpai",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
- if(data.status == 200){
- $scope.xinghaos = data.list;
- }
- });
- return;
- }
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var dat1 = [Number(res.id)]
- api_user_data.rmvData('dictionaryTree',dat1).then(function (data) {
- $scope.pinpai_show = false;
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- //品牌型号
- var dat2 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "pinpai",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
- if(data.status == 200){
- $scope.xinghaos = data.list;
- }
- });
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- // 规格编辑
- $scope.guige_edit = function (res, index) {
- $scope.guige_index = index;
- if (res.id != '' && res.id != undefined) {
- $scope.guige_panduan = "修改";
- $scope.guige_ids = res.id;
- } else {
- $scope.guige_panduan = "新增";
- $scope.guige_ids = '';
- }
- $scope.guige_show = true;
- }
- // 规格取消
- $scope.guige_quxiao = function () {
- $scope.guige_show = false;
- }
- //规格完成
- $scope.guige_wancheng = function (res) {
- for (var k = 0; k < $scope.guiges.length; k++) {
- $scope.guige_shuzu.push($scope.guiges[k].name)
- }
- if ($scope.guige_ids != '' && $scope.guige_ids != undefined) {
- if ($scope.guige_ipt[res] == '' || $scope.guige_ipt[res] == undefined) {
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值不能为空!",
- type: "error"
- });
- } else {
- if ($scope.guige_shuzu.indexOf($scope.guige_ipt[res]) !== -1) {
- SweetAlert.swal({
- title: "修改失败",
- text: "修改值已存在!",
- type: "error"
- });
- } else {
- var dat1 = {
- dictionaryTree: {
- id: $scope.guige_ids,
- key: "guige",
- name: $scope.guige_ipt[res],
- value: $scope.guige_ipt[res],
- level: 1,
- system: 0,
- deleted: 0
- }
- }
- api_user_data.addData('dictionaryTree',dat1).then(function (data) {
- $scope.guige_show = false;
- $scope.guige_shuzu = [];
- SweetAlert.swal({
- title: "修改成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- //品牌型号
- var dat2 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "guige",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
- if(data.status == 200){
- $scope.guiges = data.list;
- }
- });
- });
- }
- }
- } else {
- if ($scope.guige_ipt[res] == '' || $scope.guige_ipt[res] == undefined) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值不能为空!",
- type: "error"
- });
- } else {
- if ($scope.guige_shuzu.indexOf($scope.guige_ipt[res]) !== -1) {
- SweetAlert.swal({
- title: "新增失败",
- text: "新增值已存在!",
- type: "error"
- });
- } else {
- var dat = {
- dictionaryTree: {
- key: "guige",
- name: $scope.guige_ipt[res],
- value: $scope.guige_ipt[res],
- level: 1,
- system: 0,
- deleted: 0,
- parent: $scope.ids
- }
- }
- api_user_data.addData('dictionaryTree', dat).then(function (data) {
- $scope.guige_show = false;
- $scope.guige_shuzu = [];
- SweetAlert.swal({
- title: "新增成功",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- //品牌型号
- var dat1 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "guige",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat1).then(function (data) {
- if(data.status == 200){
- $scope.guiges = data.list;
- }
- });
- });
- }
- }
- }
- }
- //规格删除
- $scope.guige_del = function (res) {
- if(!res.id){
- $scope.guige_show = false;
- //品牌型号
- var dat2 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "guige",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
- if(data.status == 200){
- if(data.status == 200){
- $scope.guiges = data.list;
- }
- }
- });
- return;
- }
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- var dat1 = [Number(res.id)]
- api_user_data.rmvData('dictionaryTree',dat1).then(function (data) {
- $scope.guige_show = false;
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- //品牌型号
- var dat2 = {
- idx: 0,
- sum: 999,
- dictionaryTree: {
- "key": "guige",
- "parent": $scope.ids
- }
- }
- api_user_data.fetchDataList('dictionaryTree', dat2).then(function (data) {
- if(data.status == 200){
- $scope.guiges = data.list;
- }
- });
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- $scope.refreshDat_name();
- }]);
|