changeOrderMx.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" :disabled="tableData.length === 0" @click="onShow">明细变更</el-button>
  4. <el-dialog title="明细变更" append-to-body :visible.sync="dialogVisible" width="900px">
  5. <el-table
  6. class="normal-margin"
  7. :data="listData"
  8. style="width: 100%"
  9. @close="onClose"
  10. border
  11. size="small">
  12. <el-table-column
  13. prop="itemname"
  14. label="产品名称"
  15. width="180">
  16. </el-table-column>
  17. <el-table-column
  18. prop="itemno"
  19. label="产品编号"
  20. width="180">
  21. </el-table-column>
  22. <el-table-column
  23. prop="erpitemno"
  24. label="erp编号"
  25. width="180">
  26. </el-table-column>
  27. <el-table-column
  28. prop="model"
  29. label="型号"
  30. width="150">
  31. <template slot-scope="scope">
  32. <p><span>{{scope.row.model}}</span></p>
  33. </template>
  34. </el-table-column>
  35. <el-table-column
  36. prop="spec"
  37. label="规格"
  38. width="150">
  39. <template slot-scope="scope">
  40. <p><span>{{scope.row.spec}}</span></p>
  41. </template>
  42. </el-table-column>
  43. <el-table-column
  44. prop="qty"
  45. label="原数量"
  46. width="180">
  47. <template slot-scope="scope">
  48. <span>{{scope.row.qty}}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. prop="deliedqty"
  53. label="已发数量"
  54. width="180">
  55. <template slot-scope="scope">
  56. <span>{{scope.row.deliedqty}}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. prop="undeliqty"
  61. label="未发数量"
  62. width="180">
  63. <template slot-scope="scope">
  64. <span>{{scope.row.undeliqty}}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. v-if="siteid === 'HY'"
  69. prop="newdeliverydate"
  70. label="变更交期"
  71. width="175"
  72. fixed="right">
  73. <template slot-scope="scope">
  74. <el-date-picker
  75. size="mini"
  76. style="width: 150px"
  77. v-model="scope.row.newdeliverydate"
  78. @focus="DateFocus(scope.row.deliverydate)"
  79. format="yyyy-MM-dd"
  80. value-format="yyyy-MM-dd"
  81. type="date"
  82. :picker-options="pickerOptions"
  83. placeholder="选择日期">
  84. </el-date-picker>
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="newvalue"
  89. label="变更数量"
  90. width="180"
  91. fixed="right">
  92. <template slot-scope="scope">
  93. <el-input size="mini" @input="onInput(scope.row,scope.$index)" v-model="scope.row.newvalue" ></el-input>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <el-form :model="form" label-position="top" size="small">
  98. <el-form-item label="变更备注" :label-width="formLabelWidth">
  99. <el-input v-model="form.remarks" type="textarea" :autosize="{minRows:5}" placeholder="输入变更备注" autocomplete="off"></el-input>
  100. </el-form-item>
  101. </el-form>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button @click="onClose" size="small">取 消</el-button>
  104. <el-button type="primary" @click="submit" size="small">确 定</el-button>
  105. </div>
  106. </el-dialog>
  107. </div>
  108. </template>
  109. <script>
  110. export default {
  111. props:['data','tableData'],
  112. data () {
  113. let that = this
  114. return {
  115. pickerOptions:{
  116. disabledDate(time){
  117. let newDate = new Date(that.deliverydate)
  118. newDate = newDate.getFullYear() + '-' + (newDate.getMonth() + 1) + '-' + newDate.getDate()
  119. let newTime = time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate()
  120. if (time < new Date(new Date().getTime() - 24 * 60 * 60 * 1000 ) || newTime === newDate) {
  121. return true; // 禁用日期
  122. }
  123. return false; // 可选日期
  124. }
  125. },
  126. formLabelWidth:'80px',
  127. listData:[],
  128. dialogVisible:false,
  129. form:{
  130. qty:''
  131. },
  132. deliverydate:'',
  133. siteid:JSON.parse(sessionStorage.getItem('active_account')).siteid
  134. }
  135. },
  136. methods:{
  137. DateFocus(val){
  138. this.deliverydate = val
  139. },
  140. onShow () {
  141. this.listData = this.tableData.map(e=>{
  142. e.newvalue = this.siteid === 'HY'?'':0
  143. return e
  144. })
  145. this.dialogVisible = true
  146. },
  147. onClose(){
  148. this.form.remarks = ''
  149. this.listData = this.tableData.map(e=>{
  150. e.newvalue = ''
  151. e.newdeliverydate = ''
  152. return e
  153. })
  154. this.dialogVisible = false
  155. },
  156. onInput(row,index) {
  157. row.newvalue = row.newvalue.replace(/[^\d]/g, '');
  158. this.$set(this.listData,index,row)
  159. },
  160. checkRowData () {
  161. let valid = true
  162. let arr = this.listData.filter((row,index)=>{
  163. if (row.newvalue > row.qty) {
  164. this.$message({
  165. message:row.itemname+"变更数量不能大于原数量",
  166. type:"error",
  167. offset:index * 60
  168. })
  169. return row
  170. } else if (row.newvalue < row.deliedqty) {
  171. this.$message({
  172. message:row.itemname+"变更数量不能小于已发货数量",
  173. type:"error",
  174. offset:index * 60
  175. })
  176. return row
  177. }
  178. })
  179. if (arr.length > 0) {
  180. return false
  181. } else {
  182. return true
  183. }
  184. },
  185. async submit () {
  186. if (this.checkRowData()) {
  187. const res = await this.$api.requested({
  188. "id": 20221110145302,
  189. "content": {
  190. "sa_orderid":this.data.sa_orderid,//订单ID
  191. "type":"数量",//调整类型,目前只支持数量
  192. "remarks":this.data.remarks,
  193. "itemifnos":this.listData.map(e=>{
  194. return {
  195. sa_orderitemsid:e.sa_orderitemsid,
  196. itemid:e.itemid,
  197. newvalue:e.newvalue,
  198. newdeliverydate:e.newdeliverydate?e.newdeliverydate:''
  199. }
  200. })
  201. }
  202. })
  203. this.tool.showMessage(res,()=>{
  204. this.dialogVisible = false
  205. this.$emit('onSuccess')
  206. })
  207. }
  208. }
  209. }
  210. }
  211. </script>
  212. <style>
  213. </style>