From 642b103206a54923a460ee36550f275b22d6f09c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 11 三月 2023 17:03:02 +0800
Subject: [PATCH] 2023-03-11

---
 public/options.json                                              |   10 
 src/tabviews/zshare/actionList/normalbutton/mkcounter/index.scss |  117 ++++++++++++++
 src/menu/components/share/actioncomponent/actionform/index.jsx   |    3 
 package-lock.json                                                |    6 
 src/menu/components/card/cardcellcomponent/dragaction/index.scss |   67 ++++++++
 src/menu/components/share/actioncomponent/formconfig.jsx         |   26 +++
 src/tabviews/zshare/actionList/normalbutton/index.jsx            |  103 +++++++++---
 src/tabviews/zshare/actionList/normalbutton/mkcounter/index.jsx  |  116 ++++++++++++++
 src/menu/components/card/cardcellcomponent/dragaction/action.jsx |    4 
 9 files changed, 413 insertions(+), 39 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index f445383..40ebbc0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5415,9 +5415,9 @@
       }
     },
     "caniuse-lite": {
-      "version": "1.0.30001399",
-      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001399.tgz",
-      "integrity": "sha512-4vQ90tMKS+FkvuVWS5/QY1+d805ODxZiKFzsU8o/RsVJz49ZSRR8EjykLJbqhzdPgadbX6wB538wOzle3JniRA=="
+      "version": "1.0.30001464",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001464.tgz",
+      "integrity": "sha512-oww27MtUmusatpRpCGSOneQk2/l5czXANDSFvsc7VuOQ86s3ANhZetpwXNf1zY/zdfP63Xvjz325DAdAoES13g=="
     },
     "canvg": {
       "version": "3.0.10",
diff --git a/public/options.json b/public/options.json
index bedcbee..4e405d0 100644
--- a/public/options.json
+++ b/public/options.json
@@ -1,12 +1,12 @@
 {
-  "appId": "202108312122504607B107A83F55B40C98CCF",
-  "appkey": "20210831212235413F287EC3BF489424496C8",
+  "appId": "201912040924165801464FF1788654BC5AC73",
+  "appkey": "20191106103859640976D6E924E464D029CF0",
   "mainSystemApi": "http://sso.mk9h.cn/cloud/webapi/dostars",
   "systemType": "",
   "externalDatabase": "",
   "lineColor": "",
   "filter": "false",
-  "defaultApp": "mkindustry",
+  "defaultApp": "mk",
   "defaultLang": "zh-CN",
   "WXAppID": "",
   "WXminiAppID": "",
@@ -17,6 +17,6 @@
   "transfer": "false",
   "keepPassword": "true",
   "platforms": ["H5", "wechat", "android", "ios", "wxMiniProgram"],
-  "host": "http://demo.mk9h.cn",
-  "service": "erp_new/"
+  "host": "http://qingqiumarket.cn",
+  "service": "MKWMS/"
 }
\ No newline at end of file
diff --git a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx
index 6418290..5b2b78c 100644
--- a/src/menu/components/card/cardcellcomponent/dragaction/action.jsx
+++ b/src/menu/components/card/cardcellcomponent/dragaction/action.jsx
@@ -1,7 +1,7 @@
 import React from 'react'
 import { useDrag, useDrop } from 'react-dnd'
 import { Popover, Button, Switch, Checkbox } from 'antd'
-import { EditOutlined, CopyOutlined, CloseOutlined, FontColorsOutlined, ProfileOutlined, WarningOutlined } from '@ant-design/icons'
+import { EditOutlined, CopyOutlined, CloseOutlined, FontColorsOutlined, ProfileOutlined, WarningOutlined, PlusOutlined, MinusOutlined } from '@ant-design/icons'
 
 import { resetStyle } from '@/utils/utils-custom.js'
 import MkIcon from '@/components/mk-icon'
@@ -53,6 +53,8 @@
   if (card.OpenType === 'form') {
     if (card.formType === 'switch') {
       btnElement = (<Switch style={_style} className={card.size === 'large' ? 'ant-switch-large' : ''} size={card.size} checkedChildren={card.openText || ''} unCheckedChildren={card.closeText || ''}/>)
+    } else if (card.formType === 'counter') {
+      btnElement = (<div style={_style} className={'mk-counter ' + card.size}><span><MinusOutlined /></span><span>1</span><span><PlusOutlined /></span></div>)
     } else if (card.formType === 'radio') {
       btnElement = (<Checkbox style={_style}></Checkbox>)
     } else {
diff --git a/src/menu/components/card/cardcellcomponent/dragaction/index.scss b/src/menu/components/card/cardcellcomponent/dragaction/index.scss
index a101adb..3d44552 100644
--- a/src/menu/components/card/cardcellcomponent/dragaction/index.scss
+++ b/src/menu/components/card/cardcellcomponent/dragaction/index.scss
@@ -142,6 +142,73 @@
     height: 26px;
   }
 
+  .mk-counter {
+    display: inline-block;
+    white-space: nowrap;
+    border: 1px solid #d9d9d9;
+    font-size: 14px;
+    border-radius: 2px;
+    background: #ffffff;
+    span {
+      display: inline-block;
+      height: 20px;
+      line-height: 22px;
+      vertical-align: top;
+      text-align: center;
+    }
+    span:first-child {
+      width: 22px;
+      text-align: center;
+      font-size: 12px;
+      border-right: 1px solid #d9d9d9;
+    }
+    span:nth-child(2) {
+      width: 42px;
+    }
+    span:last-child {
+      width: 22px;
+      text-align: center;
+      font-size: 12px;
+      border-left: 1px solid #d9d9d9;
+    }
+  }
+  .mk-counter.small {
+    font-size: 12px;
+    span {
+      height: 18px;
+      line-height: 19px;
+    }
+    span:first-child {
+      width: 20px;
+      font-size: 10px;
+    }
+    span:nth-child(2) {
+      width: 38px;
+    }
+    span:last-child {
+      width: 20px;
+      font-size: 10px;
+    }
+  }
+  .mk-counter.large {
+    font-size: 16px;
+    span {
+      height: 24px;
+      line-height: 25px;
+    }
+    span:first-child {
+      width: 26px;
+      font-size: 13px;
+    }
+    span:nth-child(2) {
+      width: 48px;
+    }
+    span:last-child {
+      width: 26px;
+      font-size: 13px;
+    }
+  }
+
   .card-cell > div {
     background-position: center center;
     background-repeat: no-repeat;
diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx
index 740b4a2..30473b8 100644
--- a/src/menu/components/share/actioncomponent/actionform/index.jsx
+++ b/src/menu/components/share/actioncomponent/actionform/index.jsx
@@ -243,6 +243,8 @@
 
       if (this.record.formType === 'switch') {
         shows.push('field', 'size', 'openVal', 'closeVal', 'openText', 'closeText')
+      } else if (this.record.formType === 'counter') {
+        shows.push('field', 'size', 'min', 'max', 'decimal')
       } else if (this.record.formType === 'radio') {
         shows.push('field', 'checkType', 'openVal', 'closeVal')
       } else {
@@ -799,6 +801,7 @@
 
         content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
       } else if (item.type === 'number') {
+        initVal = item.initVal || item.initVal === 0 ? item.initVal : ''
         rules = [
           { required: item.required, message: '璇疯緭鍏�' + item.label + '!' }
         ]
diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx
index c1f4bd9..135daca 100644
--- a/src/menu/components/share/actioncomponent/formconfig.jsx
+++ b/src/menu/components/share/actioncomponent/formconfig.jsx
@@ -266,6 +266,9 @@
       }, {
         value: 'radio',
         text: '鍕鹃�夋'
+      }, {
+        value: 'counter',
+        text: '璁℃暟鍣�'
       }, 
       ...formTypes]
     },
@@ -1026,7 +1029,7 @@
     {
       type: 'radio',
       key: 'size',
-      label: '寮�鍏冲昂瀵�',
+      label: '灏哄',
       initVal: card.size || 'default',
       options: [{
         value: 'large',
@@ -1061,6 +1064,27 @@
       required: false
     },
     {
+      type: 'number',
+      key: 'min',
+      label: '鏈�灏忓��',
+      initVal: card.min,
+      required: false
+    },
+    {
+      type: 'number',
+      key: 'max',
+      label: '鏈�澶у��',
+      initVal: card.max,
+      required: false
+    },
+    {
+      type: 'number',
+      key: 'decimal',
+      label: '灏忔暟浣�',
+      initVal: card.decimal || 0,
+      required: true
+    },
+    {
       type: 'text',
       key: 'closeVal',
       label: '鍏抽棴鍊�',
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 29ac925..4b9f777 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -13,6 +13,7 @@
 import { updateForm } from '@/utils/utils-update.js'
 import MKEmitter from '@/utils/events.js'
 import MkIcon from '@/components/mk-icon'
+import MkCounter from './mkcounter'
 // import './index.scss'
 
 const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
@@ -43,7 +44,8 @@
     disabled: false,
     hidden: false,
     autoMatic: false,
-    check: false
+    check: false,
+    count: 0
   }
 
   moduleParams = null
@@ -59,7 +61,18 @@
     
     if (btn.OpenType === 'form') {
       let data = selectedData && selectedData[0] ? selectedData[0] : null
-      this.setState({check: data && data[btn.field] === btn.openVal})
+      if (btn.formType === 'counter') {
+        let count = 0
+        if (data && data[btn.field]) {
+          count = +data[btn.field]
+          if (isNaN(count)) {
+            count = 0
+          }
+        }
+        this.setState({count: count })
+      } else {
+        this.setState({check: data && data[btn.field] === btn.openVal})
+      }
     } else if (btn.OpenType === 'formSubmit') {
       this.setState({
         selines: selectedData || []
@@ -95,7 +108,18 @@
 
     if (btn.OpenType === 'form') {
       let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null
-      this.setState({check: data && data[btn.field] === btn.openVal})
+      if (btn.formType === 'counter') {
+        let count = 0
+        if (data && data[btn.field]) {
+          count = +data[btn.field]
+          if (isNaN(count)) {
+            count = 0
+          }
+        }
+        this.setState({count: count })
+      } else {
+        this.setState({check: data && data[btn.field] === btn.openVal})
+      }
     } else if (btn.OpenType === 'formSubmit') {
       this.setState({
         selines: nextProps.selectedData || []
@@ -352,29 +376,41 @@
         this.improveAction()
       })
     } else if (btn.OpenType === 'form') {
-      this.setState({
-        loading: true,
-        check: !this.state.check
-      }, () => {
-        let type = 'text'
-        let fieldlen = 50
-        let value = this.state.check ? btn.openVal : btn.closeVal
-
-        if (typeof(value) === 'number') {
-          type = 'number'
-          fieldlen = 0
-        }
-        
+      if (btn.formType === 'counter') {
         let item = {
-          type: type,
+          type: 'number',
           readin: true,
           writein: true,
-          fieldlen: fieldlen,
+          fieldlen: btn.decimal || 0,
           key: btn.field,
-          value: value
+          value: this.state.count
         }
-        this.execSubmit(data, () => { this.setState({loading: false})}, [item])
-      })
+        this.execSubmit(data, () => {}, [item])
+      } else {
+        this.setState({
+          loading: true,
+          check: !this.state.check
+        }, () => {
+          let type = 'text'
+          let fieldlen = 50
+          let value = this.state.check ? btn.openVal : btn.closeVal
+  
+          if (typeof(value) === 'number') {
+            type = 'number'
+            fieldlen = 0
+          }
+          
+          let item = {
+            type: type,
+            readin: true,
+            writein: true,
+            fieldlen: fieldlen,
+            key: btn.field,
+            value: value
+          }
+          this.execSubmit(data, () => { this.setState({loading: false})}, [item])
+        })
+      }
     }
 
     if (window.GLOB.systemType === 'production') {
@@ -1944,11 +1980,13 @@
     }
 
     if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 鎵ц鎴愬姛
-      notification.success({
-        top: 92,
-        message: res.message || '鎵ц鎴愬姛锛�',
-        duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
-      })
+      if (btn.formType !== 'counter' || res.message) {
+        notification.success({
+          top: 92,
+          message: res.message || '鎵ц鎴愬姛锛�',
+          duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
+        })
+      }
     } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
         title: res.message || '鎵ц鎴愬姛锛�'
@@ -2382,7 +2420,7 @@
       MKEmitter.emit('popclose')
     } else if (btn.execError !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
-    } else if (btn.OpenType === 'form') {
+    } else if (btn.OpenType === 'form' && btn.formType !== 'counter') {
       let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null
       this.setState({check: data && data[btn.field] === btn.openVal})
     }
@@ -2760,15 +2798,22 @@
     }
   }
 
+  changeCount = (count) => {
+    this.setState({count}, () => {
+      this.actionTrigger()
+    })
+  }
+
   render() {
     const { btn } = this.props
-    const { loadingNumber, loadingTotal, loading, disabled, hidden, check } = this.state
+    const { loadingNumber, loadingTotal, loading, disabled, hidden, check, count } = this.state
 
     if (hidden) return null
-
     if (btn.OpenType === 'form') {
       if (btn.formType === 'switch') { 
         return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/>
+      } else if (btn.formType === 'counter') {
+        return <MkCounter count={count} disabled={disabled} btn={btn} onChange={this.changeCount}/>
       } else if (btn.formType === 'radio') {
         return <Checkbox className={btn.checkType || ''} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox>
       } else {
diff --git a/src/tabviews/zshare/actionList/normalbutton/mkcounter/index.jsx b/src/tabviews/zshare/actionList/normalbutton/mkcounter/index.jsx
new file mode 100644
index 0000000..5c0bfe3
--- /dev/null
+++ b/src/tabviews/zshare/actionList/normalbutton/mkcounter/index.jsx
@@ -0,0 +1,116 @@
+import React, {Component} from 'react'
+import PropTypes from 'prop-types'
+import { message, InputNumber } from 'antd'
+import { PlusOutlined, MinusOutlined } from '@ant-design/icons'
+
+import './index.scss'
+
+class MkCounter extends Component {
+  static propTpyes = {
+    count: PropTypes.number,
+    btn: PropTypes.object,
+    disabled: PropTypes.any,
+    onChange: PropTypes.func
+  }
+
+  state = {
+    count: 0,
+    orival: 0
+  }
+
+  timer = null
+
+  UNSAFE_componentWillMount() {
+    this.setState({count: this.props.count, orival: this.props.count})
+  }
+
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    this.setState({count: nextProps.count, orival: nextProps.count})
+  }
+
+  minus = () => {
+    const { btn } = this.props
+    const { count } = this.state
+    
+    let val = count - 1
+
+    if (btn.min !== '' && val < btn.min) {
+      message.warning(`涓嶅彲灏忎簬${btn.min}!`)
+      return
+    } else if (btn.max !== '' && val > btn.max) {
+      message.warning(`涓嶅彲澶т簬${btn.max}!`)
+      return
+    }
+
+    this.setState({count: val, orival: val})
+
+    clearTimeout(this.timer)
+
+    this.timer = setTimeout(() => {
+      this.props.onChange(val)
+    }, 1000)
+  }
+
+  plus = () => {
+    const { btn } = this.props
+    const { count } = this.state
+    
+    let val = count + 1
+
+    if (btn.min !== '' && val < btn.min) {
+      message.warning(`涓嶅彲灏忎簬${btn.min}!`)
+      return
+    } else if (btn.max !== '' && val > btn.max) {
+      message.warning(`涓嶅彲澶т簬${btn.max}!`)
+      return
+    }
+
+    this.setState({count: val, orival: val})
+
+    clearTimeout(this.timer)
+
+    this.timer = setTimeout(() => {
+      this.props.onChange(val)
+    }, 1000)
+  }
+
+  submit = () => {
+    const { btn } = this.props
+    const { count, orival } = this.state
+
+    if (count === '') {
+      message.warning(`涓嶅彲涓虹┖!`)
+      this.setState({count: 0})
+      return
+    } else if (btn.min !== '' && count < btn.min) {
+      message.warning(`涓嶅彲灏忎簬${btn.min}!`)
+      return
+    } else if (btn.max !== '' && count > btn.max) {
+      message.warning(`涓嶅彲澶т簬${btn.max}!`)
+      return
+    }
+
+    if (orival === count) return
+
+    clearTimeout(this.timer)
+
+    this.timer = setTimeout(() => {
+      this.props.onChange(count)
+    }, 1000)
+  }
+
+  render() {
+    const { btn, disabled } = this.props
+    const { count } = this.state
+
+    return (
+      <div onClick={(e) => e.stopPropagation()} className={'mk-btn-counter ' + (btn.size || '') + (disabled ? ' mk-disabled' : '')} style={btn.style}>
+        <span onClick={this.minus}><MinusOutlined /></span>
+        <span><InputNumber value={count} onChange={(val) => this.setState({count: val})} onBlur={this.submit} onPressEnter={this.submit}/></span>
+        <span onClick={this.plus}><PlusOutlined /></span>
+      </div>
+    )
+  }
+}
+
+export default MkCounter
\ No newline at end of file
diff --git a/src/tabviews/zshare/actionList/normalbutton/mkcounter/index.scss b/src/tabviews/zshare/actionList/normalbutton/mkcounter/index.scss
new file mode 100644
index 0000000..b31ba07
--- /dev/null
+++ b/src/tabviews/zshare/actionList/normalbutton/mkcounter/index.scss
@@ -0,0 +1,117 @@
+.mk-btn-counter {
+  position: relative;
+  display: inline-block;
+  white-space: nowrap;
+  border: 1px solid #d9d9d9;
+  font-size: 14px;
+  border-radius: 2px;
+  width: auto!important;
+  max-width: auto!important;
+  background: #ffffff;
+  overflow: hidden;
+
+  >span {
+    display: inline-block;
+    height: 20px;
+    line-height: 22px;
+    vertical-align: top;
+    text-align: center;
+  }
+  >span:first-child {
+    position: relative;
+    width: 22px;
+    text-align: center;
+    font-size: 12px;
+    cursor: pointer;
+  }
+  >span:first-child:after {
+    content: ' ';
+    display: inline-block;
+    width: 1px;
+    height: 26px;
+    background-color: #d9d9d9;
+    position: absolute;
+    right: 0px;
+  }
+  >span:nth-child(2) {
+    width: 42px;
+    .ant-input-number {
+      border: none;
+      border-radius: 0;
+      height: auto;
+      box-shadow: none!important;
+      .ant-input-number-handler-wrap {
+        display: none;
+      }
+      .ant-input-number-input {
+        padding: 0;
+        height: auto;
+        text-align: center;
+      }
+    }
+  }
+  >span:last-child {
+    position: relative;
+    width: 22px;
+    text-align: center;
+    font-size: 12px;
+    cursor: pointer;
+  }
+  >span:last-child::before {
+    content: ' ';
+    display: inline-block;
+    width: 1px;
+    height: 26px;
+    background-color: #d9d9d9;
+    position: absolute;
+    left: 0px;
+  }
+}
+.mk-btn-counter.mk-disabled .ant-input-number-input {
+  color: #bcbcbc !important;
+}
+.mk-btn-counter.mk-disabled::after {
+  content: ' ';
+  display: block;
+  position: absolute;
+  left: 0;
+  right: 0;
+  top: 0;
+  bottom: 0;
+}
+.mk-btn-counter.small {
+  font-size: 12px;
+  >span {
+    height: 18px;
+    line-height: 19px;
+  }
+  >span:first-child {
+    width: 20px;
+    font-size: 10px;
+  }
+  >span:nth-child(2) {
+    width: 38px;
+  }
+  >span:last-child {
+    width: 20px;
+    font-size: 10px;
+  }
+}
+.mk-btn-counter.large {
+  font-size: 16px;
+  >span {
+    height: 24px;
+    line-height: 25px;
+  }
+  >span:first-child {
+    width: 26px;
+    font-size: 13px;
+  }
+  >span:nth-child(2) {
+    width: 48px;
+  }
+  >span:last-child {
+    width: 26px;
+    font-size: 13px;
+  }
+}
\ No newline at end of file

--
Gitblit v1.8.0