Commit 102eb481 authored by lujunye's avatar lujunye

修改输入限制

parent 94a17559
......@@ -10,7 +10,7 @@ import UIKit
protocol YuShouWeiKuanFaHuoCellDelegate {
func YuShouWeiKuanFaHuoCellString(str:String)
}
class YuShouWeiKuanFaHuoCell: UITableViewCell {
class YuShouWeiKuanFaHuoCell: UITableViewCell,UITextFieldDelegate{
var delegate:YuShouWeiKuanFaHuoCellDelegate?
@IBOutlet weak var textTF: UITextField!
@IBOutlet weak var nameLbl: UILabel!
......@@ -18,14 +18,21 @@ class YuShouWeiKuanFaHuoCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
self.selectionStyle = .none
textTF.addTarget(self, action: #selector(textChange(tf:)), for: .allEditingEvents)
textTF.delegate = self
// Initialization code
}
@objc func textChange(tf:UITextField){
if tf.text != nil {
delegate?.YuShouWeiKuanFaHuoCellString(str: tf.text!)
func textFieldDidEndEditing(_ textField: UITextField) {
if isPurnInt(string: textField.text!) {
delegate?.YuShouWeiKuanFaHuoCellString(str: formatShowNumber(value: textField.text!))
}else{
HUD.flash(.label("请输入正确的数据"), delay: 1.2)
textField.text = "0"
}
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
......
......@@ -1506,11 +1506,9 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
}
}
func YuShouWeiKuanFaHuoCellString(str: String) {
if isPurnInt(string: str) {
faHuoTime = formatShowNumber(value: str)
}else{
HUD.flash(.label("请输入正确的数据"), delay: 1.2)
}
faHuoTime = str
}
override func backAction() {
if editBtn?.titleLabel!.text == "保存"{
......
......@@ -1103,11 +1103,9 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
}
}
func YuShouWeiKuanFaHuoCellString(str: String) {
if isPurnInt(string: str) {
faHuoTime = formatShowNumber(value: str)
}else{
HUD.flash(.label("请输入正确的数据"), delay: 1.2)
}
faHuoTime = str
}
override func backAction() {
self.navigationController?.popViewController(animated: true)
......
......@@ -188,7 +188,7 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}
}
}
if specalArr.count > 0 {
for item in specalArr {
let str = item as! String
......@@ -394,7 +394,7 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
cell.tag = indexPath.row
cell.countTF.isUserInteractionEnabled = isAllEditing
cell.priceTF.isUserInteractionEnabled = isAllEditing
cell.isYuShou = selectYuShou
cell.countTF.text = ""
cell.priceTF.text = ""
var item:NSString = ""
......@@ -651,17 +651,24 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
listTbv.reloadData()
}
func PuTongJieTiDelAction(sender: PuTongJieTiCell) {
jieTiArr.remove(at: sender.tag)
listTbv.reloadData()
}
func PuTongJieTiContent(price: String, count: String, cell: PuTongJieTiCell) {
if selectYuShou {
specalArr.insert("\(price)_\(count)", at: cell.tag)
specalArr.remove(at: cell.tag+1)
if selectYuShou {
specalArr.remove(at: sender.tag)
listTbv.reloadData()
}else{
jieTiArr.insert("\(price)_\(count)", at: cell.tag)
jieTiArr.remove(at: cell.tag+1)
jieTiArr.remove(at: sender.tag)
listTbv.reloadData()
}
}
func PuTongJieTiContentSp(price: String, count: String, cell: PuTongJieTiCell) {
specalArr.insert("\(price)_\(count)", at: cell.tag)
specalArr.remove(at: cell.tag+1)
}
func PuTongJieTiContent(price: String, count: String, cell: PuTongJieTiCell) {
jieTiArr.insert("\(price)_\(count)", at: cell.tag)
jieTiArr.remove(at: cell.tag+1)
}
func selectYuShou(sender: UIButton) {
......
......@@ -10,6 +10,7 @@ import UIKit
@objc protocol PuTongJieTiCellDelegate {
@objc optional func PuTongJieTiDelAction(sender:PuTongJieTiCell)
@objc optional func PuTongJieTiContent(price:String,count:String,cell:PuTongJieTiCell)
@objc optional func PuTongJieTiContentSp(price:String,count:String,cell:PuTongJieTiCell)
@objc optional func PuTongJieTiClickDone()
}
class PuTongJieTiCell: UITableViewCell,UITextFieldDelegate {
......@@ -21,31 +22,49 @@ class PuTongJieTiCell: UITableViewCell,UITextFieldDelegate {
@IBOutlet weak var priceTF: UITextField!
@IBOutlet weak var countTF: UITextField!
@IBOutlet weak var titleLbl: UILabel!
@IBOutlet weak var btn: UIButton!
var isYuShou:Bool?
override func awakeFromNib() {
super.awakeFromNib()
selectionStyle = .none
priceTF.addTarget(self, action: #selector(textChange(textF:)), for: .editingChanged)
countTF.addTarget(self, action: #selector(textChange(textF:)), for: .editingChanged)
priceTF.tag = 0
countTF.tag = 1
countTF.keyboardType = .numberPad
priceTF.keyboardType = .decimalPad
priceTF.returnKeyType = .done
priceTF.delegate = self
countTF.delegate = self
// Initialization code
}
func textFieldDidEndEditing(_ textField: UITextField) {
if textField == priceTF{//价格
if isPurnNumber(str: textField.text!) == false{
HUD.flash(.label("请输入正确的价格"), delay: 1.2)
textField.text = "0"
return
}
priceTF.text = formatShowNumber(value: textField.text!)
}else{//数量
if isPurnInt(string: textField.text!) == false{
HUD.flash(.label("请输入正确的数量"), delay: 1.2)
textField.text = "1"
return
}
countTF.text = formatShowNumber(value: textField.text!)
}
if isYuShou! {
delegate?.PuTongJieTiContentSp?(price: priceTF.text!, count: countTF.text!, cell: self)
}else{
delegate?.PuTongJieTiContent?(price: priceTF.text!, count: countTF.text!, cell: self)
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
((delegate?.PuTongJieTiClickDone?()) != nil)
}
@objc func textChange(textF:UITextField){
delegate?.PuTongJieTiContent?(price: priceTF.text!, count: countTF.text!, cell: self)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment