productlist.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <el-row :gutter="10">
  3. <el-col :span="setcol">
  4. <el-button style="margin:0 0 10px 0px" size="small" type="primary" @click="setcol = setcol === 24?12:24">{{setcol === 24?'添 加':'取 消'}}</el-button>
  5. <el-table
  6. ref="multipleTable"
  7. :data="tableData"
  8. height="500px"
  9. style="width: 100%;"
  10. size="small"
  11. stripe
  12. border>
  13. <!-- <el-table-column
  14. type="selection"
  15. width="55"
  16. align="center">
  17. </el-table-column> -->
  18. <el-table-column
  19. prop="rowno"
  20. label="行号"
  21. width="50">
  22. </el-table-column>
  23. <el-table-column
  24. prop="itemname"
  25. label="产品名称"
  26. width="180">
  27. </el-table-column>
  28. <el-table-column
  29. prop="itemno"
  30. label="产品编号"
  31. width="180">
  32. </el-table-column>
  33. <el-table-column
  34. label="型号/规格">
  35. <template slot-scope="scope">
  36. <p><span>{{scope.row.model}}</span>&nbsp;/&nbsp;<span>{{scope.row.spec}}</span></p>
  37. </template>
  38. </el-table-column>
  39. <el-table-column
  40. label="数量"
  41. width="180">
  42. <template slot-scope="scope">
  43. <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="data.status === '新建'" size="mini" v-model="scope.row.qty" :min="scope.row.orderminqty" :step="scope.row.orderaddqty" label="输入数量" @change="qtyChange(scope.row,scope.$index)"></el-input-number>
  44. <span v-else>{{scope.row.qty}}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. label="需求日期"
  49. width="200">
  50. <template slot="header" slot-scope="scope">
  51. <div>
  52. <el-date-picker
  53. style="width:180px"
  54. v-if="data.status === '新建'"
  55. v-model="value2"
  56. value-format="yyyy-MM-dd"
  57. slot="reference"
  58. align="right"
  59. type="date"
  60. size="mini"
  61. placeholder="一键交期"
  62. @change="dateChange(scope.row)">
  63. </el-date-picker>
  64. <span v-else>需求日期</span>
  65. </div>
  66. </template>
  67. <template slot-scope="scope">
  68. <el-date-picker
  69. v-if="scope.row.delivery > 0 && data.status === '新建'"
  70. v-model="scope.row.needdate"
  71. type="date"
  72. placeholder="选择日期"
  73. value-format="yyyy-MM-dd"
  74. size="mini"
  75. style="width:150px"
  76. :picker-options="pickerOptions"
  77. @change="onDateChange(scope.row)"
  78. @focus="setPickerOptions(scope.row)">
  79. </el-date-picker>
  80. <div v-else>
  81. <p v-if="scope.row.delivery === 0 ">不管控交期</p>
  82. <p v-else>{{scope.row.needdate}}</p>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column
  87. prop="deliverydate"
  88. label="回复交期"
  89. width="120">
  90. </el-table-column>
  91. <el-table-column
  92. prop="unit"
  93. label="计量单位"
  94. width="90">
  95. <template slot-scope="scope">
  96. <el-tag size="mini" type="info" effect="plain">{{scope.row.unit}}</el-tag>
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. prop="price"
  101. label="价格"
  102. width="90">
  103. <template slot-scope="scope">
  104. <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price,2)}}</p>
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. label="折后价格"
  109. prop="totalprice">
  110. <template slot-scope="scope">
  111. <p style="color:red;font-weight:500">¥&nbsp;{{scope.row.price}}</p>
  112. </template>
  113. </el-table-column>
  114. <el-table-column
  115. label="小计"
  116. width="150">
  117. <template slot-scope="scope">
  118. <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price * scope.row.qty,2)}}</p>
  119. </template>
  120. </el-table-column>
  121. <el-table-column v-if="data.status === '新建'" width="90" fixed="right">
  122. <template slot-scope="scope">
  123. <el-button type="text" size="mini" @click="deleteOrderProduct(scope.row)">删 除</el-button>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. <div style="margin-top:16px;text-align:right">
  128. <el-pagination
  129. background
  130. small
  131. @size-change="handleSizeChange"
  132. @current-change="handleCurrentChange"
  133. :current-page="currentPage"
  134. :page-size="param.content.pageSize"
  135. layout="total, prev, pager, next, jumper"
  136. :total="total">
  137. </el-pagination>
  138. </div>
  139. </el-col>
  140. <el-col :span="24 - setcol">
  141. <addProduct :data="data" @onConfirm="onConfirm"></addProduct>
  142. </el-col>
  143. </el-row>
  144. </template>
  145. <script>
  146. import addProduct from '@/template/orderCanUseProduct/index.vue'
  147. export default {
  148. props:['data','type'],
  149. data () {
  150. return {
  151. setcol:24,
  152. dataRefresh:true,
  153. tableData:[],
  154. param:{
  155. "id": 20221109093902,
  156. "content": {
  157. "sa_orderid": 0, //订单ID
  158. "pageNumber": 1,
  159. "pageSize": 20,
  160. "where": {
  161. "condition": ""
  162. }
  163. },
  164. },
  165. pickerOptions: {
  166. disabledDate(time) {
  167. return time.getTime() < (Date.now() - 24 * 3600 * 1000);
  168. },
  169. },
  170. total:0,
  171. currentPage:0,
  172. time: null,
  173. value2:''
  174. }
  175. },
  176. components:{
  177. addProduct
  178. },
  179. methods:{
  180. async listData () {
  181. this.param.content.sa_orderid = this.$route.query.id
  182. const res = await this.$api.requested(this.param)
  183. this.tableData = res.data
  184. this.total = res.total
  185. this.currentPage = res.pageNumber
  186. },
  187. handleSizeChange(val) {
  188. // console.log(`每页 ${val} 条`);
  189. this.params.content.pageSize = val
  190. this.listData()
  191. },
  192. handleCurrentChange(val) {
  193. // console.log(`当前页: ${val}`);
  194. this.params.content.pageNumber = val
  195. this.listData()
  196. },
  197. async deleteOrderProduct (row) {
  198. const res = await this.$api.requested({
  199. "id": 20221109093702,
  200. "content": {
  201. "sa_orderid":this.$route.query.id,
  202. "sa_orderitemsids": [row.sa_orderitemsid]
  203. },
  204. })
  205. this.tool.showMessage(res,()=>{
  206. this.listData()
  207. this.$emit('onSuccess')
  208. })
  209. },
  210. // async updateOrderProduct (val) {
  211. // const res = await this.$api.requested({
  212. // "id": 20221110145302,
  213. // "content": val
  214. // })
  215. // this.$emit('onSuccess')
  216. // },
  217. qtyChange (val,index) {
  218. let that = this
  219. this.$set(this.tableData,index,val)
  220. // // 防抖
  221. if(this.time !== null){
  222. clearTimeout(this.time);
  223. }
  224. this.time = setTimeout(() => {
  225. that.updateOrder({
  226. "sa_orderid": this.data.sa_orderid, //订单ID
  227. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  228. "sa_contractid": this.data.contacts.contactsid, //合同ID
  229. "type": this.data.type, //订单类型
  230. "items": [{
  231. "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
  232. "itemid": val.itemid, //商品ID
  233. "qty": val.qty, //数量
  234. "needdate": val.needdate//可以不传,修改交期
  235. }]
  236. })
  237. },500)
  238. },
  239. onDateChange (val){
  240. let that = this
  241. that.value2 = ''
  242. that.updateOrder({
  243. "sa_orderid": this.data.sa_orderid, //订单ID
  244. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  245. "sa_contractid": this.data.contacts.contactsid, //合同ID
  246. "type": this.data.type, //订单类型
  247. "items": [{
  248. "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
  249. "itemid": val.itemid, //商品ID
  250. "qty": val.qty, //数量
  251. "needdate": val.needdate//可以不传,修改交期
  252. }]
  253. })
  254. },
  255. async dateChange (row) {
  256. this.tableData = this.tableData.filter(e=>{
  257. if (e.delivery > 0) {
  258. e.needdate = this.value2
  259. }
  260. return e
  261. })
  262. const res = await this.$api.requested({
  263. "id": 20230104143802,
  264. "content": {
  265. "sa_orderid": this.$route.query.id,
  266. "needdate": this.value2
  267. },
  268. })
  269. },
  270. async updateOrder (val) {
  271. const res = await this.$api.requested({
  272. "id": 20221109093602,
  273. "content": val
  274. })
  275. // this.$emit('onSuccess')
  276. },
  277. setPickerOptions (val) {
  278. var startDate = val.deliverydate
  279. startDate = startDate.replace(new RegExp("-","gm"),"/")
  280. var startDateM = (new Date(startDate)).getTime()
  281. this.pickerOptions = {
  282. disabledDate(time) {
  283. return time.getTime() < startDateM;
  284. },
  285. }
  286. },
  287. // 订单添加商品
  288. async onConfirm (data) {
  289. const res = await this.$api.requested({
  290. "id": 20221109093602,
  291. "content": {
  292. "sa_orderid": this.$route.query.id, //订单ID
  293. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  294. "type": this.data.type, //订单类型
  295. "items": data.map(e=>{
  296. return {
  297. sa_orderitemsid:0,
  298. itemid:e.itemid,
  299. qty:e.orderminqty,
  300. needdate:e.deliverydate
  301. }
  302. })
  303. },
  304. })
  305. this.tool.showMessage(res,()=>{
  306. this.setcol = 24
  307. this.listData()
  308. })
  309. },
  310. },
  311. mounted () {
  312. this.listData()
  313. },
  314. watch:{
  315. value2 (val) {
  316. console.log(val)
  317. }
  318. }
  319. }
  320. </script>
  321. <style>
  322. </style>