productlist.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div>
  3. <el-row :gutter="10">
  4. <el-col :span="setcol">
  5. <div class="flex-align-center">
  6. <el-button style="margin:0 0 10px 10px" size="small" type="primary" :disabled="data.status !== '新建'" v-if="type !== 'confirmdate'" @click="drawer = true">{{setcol === 24?$t('添 加'):$t('取 消')}}</el-button>
  7. </div>
  8. <Table
  9. height="calc(100vh - 500px)"
  10. ref="multipleTable"
  11. :layout="tablecols"
  12. :data="tableData"
  13. :custom="true" :checkbox="true" fixedName="rowno orderRowno itemname itemno erpitemno model" redirect="left">
  14. <template v-slot:customcol="scope">
  15. <div v-if="scope.column.columnname === 'qty'">
  16. <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="data.status === '新建'" size="mini" v-model="scope.column.data.qty" :min="1" :max="scope.column.data.undeliqty" :label="$t(`输入数量`)" @change="rowChange(scope.column.data,scope.$index)"></el-input-number>
  17. <span v-else>{{scope.column.data.qty}}</span>
  18. </div>
  19. <div v-else-if="scope.column.columnname === 'price'">
  20. {{tool.formatAmount(scope.column.data.price,2)}}
  21. </div>
  22. <div v-else-if="scope.column.columnname === 'remarks'">
  23. <el-input v-if="data.status === '新建'" v-model="scope.column.data.remarks" :placeholder="$t(`输入订单备注`)" size="mini" @change="rowChange(scope.column.data,scope.$index)"></el-input>
  24. <p v-else>{{scope.column.data.remarks}}</p>
  25. </div>
  26. <p v-else>{{$t(scope.column.data[scope.column.columnname])}}</p>
  27. </template>
  28. <template v-slot:opreation="scope">
  29. <el-button type="text" size="mini" @click="deleteOrderProduct(scope.data)" :disabled="data.status !== '新建'">{{$t(`删 除`)}}</el-button>
  30. </template>
  31. </Table>
  32. <!-- <el-table
  33. ref="multipleTable"
  34. :data="tableData"
  35. height="500px"
  36. style="width: 100%;"
  37. size="small"
  38. stripe
  39. border>
  40. <el-table-column
  41. prop="rowno"
  42. width="100px"
  43. label="发货单行号"
  44. fixed>
  45. </el-table-column>
  46. <el-table-column
  47. prop="orderRowno"
  48. width="100px"
  49. label="订单行号"
  50. fixed>
  51. </el-table-column>
  52. <el-table-column
  53. prop="itemname"
  54. label="产品名称"
  55. fixed>
  56. </el-table-column>
  57. <el-table-column
  58. prop="itemno"
  59. fixed
  60. label="产品编码">
  61. </el-table-column>
  62. <el-table-column
  63. prop="erpitemno"
  64. label="品号"
  65. fixed>
  66. </el-table-column>
  67. <el-table-column
  68. prop="model"
  69. label="型号"
  70. fixed>
  71. </el-table-column>
  72. <el-table-column
  73. prop="spec"
  74. label="规格">
  75. </el-table-column>
  76. <el-table-column
  77. prop="unitname"
  78. label="单位">
  79. </el-table-column>
  80. <el-table-column
  81. prop="price"
  82. label="单价">
  83. <template slot-scope="scope">
  84. {{tool.formatAmount(scope.row.price,2)}}
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="qty"
  89. label="数量"
  90. width="180">
  91. <template slot-scope="scope">
  92. <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="data.STATUS === '新建'" size="mini" v-model="scope.row.qty" :min="1" :max="scope.row.undeliqty" label="输入数量" @change="rowChange(scope.row,scope.$index)"></el-input-number>
  93. <span v-else>{{scope.row.qty}}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. prop="amount"
  98. label="发货金额">
  99. </el-table-column>
  100. <el-table-column
  101. prop="undeliqty"
  102. label="未发货数量"
  103. width="100px">
  104. </el-table-column>
  105. <el-table-column
  106. label="备注"
  107. width="300"
  108. prop="remarks">
  109. <template slot-scope="scope">
  110. <el-input v-if="data.STATUS === '新建'" v-model="scope.row.remarks" placeholder="输入订单备注" size="mini" @change="rowChange(scope.row,scope.$index)"></el-input>
  111. <p v-else>{{scope.row.remarks}}</p>
  112. </template>
  113. </el-table-column>
  114. <el-table-column
  115. prop="suminqty"
  116. width="120px"
  117. label="erp即时库存">
  118. </el-table-column>
  119. <el-table-column :label="$t(`操作`)" width="90" fixed="right">
  120. <template slot-scope="scope">
  121. <el-button type="text" size="mini" @click="deleteOrderProduct(scope.row)">{{$t(`删 除`)}}</el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table> -->
  125. <div style="margin-top:16px;text-align:right">
  126. <!-- <el-pagination
  127. background
  128. small
  129. @size-change="handleSizeChange"
  130. @current-change="handleCurrentChange"
  131. :current-page="param.content.pageNumber"
  132. :page-size="param.content.pageSize"
  133. layout="total, prev, pager, next, jumper"
  134. :total="total">
  135. </el-pagination>-->
  136. <el-pagination
  137. background
  138. @size-change="handleSizeChange"
  139. @current-change="handleCurrentChange"
  140. :current-page="param.content.pageNumber"
  141. :page-sizes="[100, 50, 100, 200]"
  142. :page-size="100"
  143. layout="total,sizes, prev, pager, next, jumper"
  144. :total="total">
  145. </el-pagination>
  146. </div>
  147. </el-col>
  148. <el-col :span="24 - setcol">
  149. <el-drawer
  150. title="添加商品"
  151. :visible.sync="drawer"
  152. append-to-body
  153. size="80%"
  154. direction="rtl">
  155. <div class="drawer__panel">
  156. <addProduct :drawer="drawer" :data="data" @onConfirm="onConfirm"></addProduct>
  157. </div>
  158. </el-drawer>
  159. </el-col>
  160. </el-row>
  161. </div>
  162. </template>
  163. <script>
  164. import addProduct from '@/template/invoiceCanUseProduct/index.vue'
  165. import Table from '@/HDrpManagement/orderManage/details/tabs/table'
  166. export default {
  167. props:['type','data'],
  168. components:{addProduct,Table},
  169. data () {
  170. return {
  171. tableData:[],
  172. drawer:false,
  173. setcol:24,
  174. param:{
  175. "id": 20221115104703,
  176. "content": {
  177. "sa_orderid": 0,
  178. "pageNumber": 1,
  179. "pageSize": 100,
  180. "where": {
  181. "condition": ""
  182. }
  183. },
  184. },
  185. total:0,
  186. currentPage:0,
  187. time: null,
  188. tablecols:[]
  189. }
  190. },
  191. methods:{
  192. async listData () {
  193. this.param.content.sa_dispatchid = this.$route.query.id
  194. const res = await this.$api.requested(this.param)
  195. this.tableData = res.data
  196. this.total = res.total
  197. this.currentPage = res.pageNumber
  198. console.log(res.data);
  199. },
  200. handleSizeChange(val) {
  201. // console.log(`每页 ${val} 条`);
  202. this.param.content.pageSize = val
  203. this.listData()
  204. },
  205. handleCurrentChange(val) {
  206. // console.log(`当前页: ${val}`);
  207. this.param.content.pageNumber = val
  208. this.listData()
  209. },
  210. async deleteOrderProduct (row) {
  211. const res = await this.$api.requested({
  212. "id": 20221115104803,
  213. "content": {
  214. "sa_dispatch_itemsids": [row.sa_dispatch_itemsid]
  215. },
  216. })
  217. this.tool.showMessage(res,()=>{
  218. this.listData()
  219. this.$emit('onSuccess')
  220. })
  221. },
  222. async updateOrderProduct (val) {
  223. const res = await this.$api.requested({
  224. "id": 20221110145302,
  225. "content": val
  226. })
  227. },
  228. qtyChange (val,index) {
  229. let that = this
  230. this.$set(this.tableData,index,val)
  231. // console.log(val,this.tableData)
  232. // // 防抖
  233. if(this.time !== null){
  234. clearTimeout(this.time);
  235. }
  236. this.time = setTimeout(() => {
  237. that.updateOrderProduct({
  238. "sa_orderitemsid":val.sa_orderitemsid,
  239. "sa_orderid":this.$route.query.id,//订单ID
  240. "itemid":val.itemid,//商品ID
  241. "type":"数量",//调整类型,目前只支持数量
  242. "oldvalue":val.qty,//原值
  243. "newvalue":val.qty,//调整后值
  244. "remarks":val.remarks
  245. })
  246. },500)
  247. },
  248. // 订单添加商品
  249. async onConfirm (data) {
  250. console.log(data,'添加商品')
  251. const res = await this.$api.requested({
  252. "id": 20221115104603,
  253. "content": {
  254. "sa_dispatchid": this.$route.query.id, //订单ID
  255. "iteminfos":data.map(e=>{
  256. e.sa_dispatch_itemsid = 0
  257. e.qty=e.undeliqty
  258. e.remarks = e.remarks
  259. return e
  260. })
  261. },
  262. })
  263. this.tool.showMessage(res,()=>{
  264. this.drawer = false
  265. this.listData()
  266. this.$emit('onSuccess')
  267. })
  268. },
  269. rowChange(val,index){
  270. let that = this
  271. this.$set(this.tableData,index,val)
  272. // // 防抖
  273. if(this.time !== null){
  274. clearTimeout(this.time);
  275. }
  276. this.time = setTimeout(() => {
  277. that.updateOrder({
  278. "sa_dispatchid": this.$route.query.id, //订单ID
  279. "iteminfos": [{
  280. "sa_dispatch_itemsid": val.sa_dispatch_itemsid,//0表示新增
  281. "qty": val.qty, //数量
  282. "remarks":val.remarks
  283. }]
  284. },()=>{
  285. this.listData()
  286. })
  287. },500)
  288. },
  289. async updateOrder (val,fn) {
  290. const res = await this.$api.requested({
  291. "id": 20221115104603,
  292. "content": val
  293. })
  294. this.$emit('onSuccess')
  295. res.code === 1?fn():""
  296. },
  297. // tableCellStyle({ row, column, rowIndex, columnIndex }) {
  298. // console.log(row.taskColor, "-->row.taskColor");
  299. // let rowBackground = {};
  300. // if (columnIndex === 10 || columnIndex == 13) {
  301. // rowBackground.background = 'yellow';
  302. // } else {
  303. // rowBackground.background = "#ffffff";
  304. // }
  305. // return rowBackground;
  306. // },
  307. },
  308. mounted () {
  309. this.listData()
  310. this.tablecols = this.tool.tabelCol(this.$route.name).OrderListTable.tablecols
  311. }
  312. }
  313. </script>
  314. <style scoped>
  315. /* /deep/.el-table__fixed .el-table__row {
  316. color: red !important;
  317. } */
  318. </style>