productlist.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <el-row :gutter="10">
  3. <el-col :span="setcol">
  4. <el-button v-if="data.status === '新建'" 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.defaultprice,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;{{Math.round(scope.row.price * 100)/100}}</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;{{scope.row.defaultamount}}</p>
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. label="折后总价"
  123. width="150">
  124. <template slot-scope="scope">
  125. <p style="color:red;font-weight:500">¥&nbsp;{{scope.row.amount}}</p>
  126. </template>
  127. </el-table-column>
  128. <el-table-column v-if="data.status === '新建'" width="90" fixed="right">
  129. <template slot-scope="scope">
  130. <el-button type="text" size="mini" @click="deleteOrderProduct(scope.row)">删 除</el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <div style="margin-top:16px;text-align:right">
  135. <el-pagination
  136. background
  137. small
  138. @size-change="handleSizeChange"
  139. @current-change="handleCurrentChange"
  140. :current-page="currentPage"
  141. :page-size="param.content.pageSize"
  142. layout="total, prev, pager, next, jumper"
  143. :total="total">
  144. </el-pagination>
  145. </div>
  146. </el-col>
  147. <el-col :span="24 - setcol">
  148. <addProduct :data="data" @onConfirm="onConfirm"></addProduct>
  149. </el-col>
  150. </el-row>
  151. </template>
  152. <script>
  153. import addProduct from '@/template/orderCanUseProduct/index.vue'
  154. export default {
  155. props:['data','type'],
  156. data () {
  157. return {
  158. setcol:24,
  159. dataRefresh:true,
  160. tableData:[],
  161. param:{
  162. "id": 20221109093902,
  163. "content": {
  164. "sa_orderid": 0, //订单ID
  165. "pageNumber": 1,
  166. "pageSize": 20,
  167. "where": {
  168. "condition": ""
  169. }
  170. },
  171. },
  172. pickerOptions: {
  173. disabledDate(time) {
  174. return time.getTime() < (Date.now() - 24 * 3600 * 1000);
  175. },
  176. },
  177. total:0,
  178. currentPage:0,
  179. time: null,
  180. value2:''
  181. }
  182. },
  183. components:{
  184. addProduct
  185. },
  186. methods:{
  187. async listData () {
  188. this.param.content.sa_orderid = this.$route.query.id
  189. const res = await this.$api.requested(this.param)
  190. this.tableData = res.data
  191. this.total = res.total
  192. this.currentPage = res.pageNumber
  193. },
  194. handleSizeChange(val) {
  195. // console.log(`每页 ${val} 条`);
  196. this.params.content.pageSize = val
  197. this.listData()
  198. },
  199. handleCurrentChange(val) {
  200. // console.log(`当前页: ${val}`);
  201. this.params.content.pageNumber = val
  202. this.listData()
  203. },
  204. async deleteOrderProduct (row) {
  205. const res = await this.$api.requested({
  206. "id": 20221109093702,
  207. "content": {
  208. "sa_orderid":this.$route.query.id,
  209. "sa_orderitemsids": [row.sa_orderitemsid]
  210. },
  211. })
  212. this.tool.showMessage(res,()=>{
  213. this.listData()
  214. this.$emit('onSuccess')
  215. })
  216. },
  217. // async updateOrderProduct (val) {
  218. // const res = await this.$api.requested({
  219. // "id": 20221110145302,
  220. // "content": val
  221. // })
  222. // this.$emit('onSuccess')
  223. // },
  224. qtyChange (val,index) {
  225. let that = this
  226. this.$set(this.tableData,index,val)
  227. // // 防抖
  228. if(this.time !== null){
  229. clearTimeout(this.time);
  230. }
  231. this.time = setTimeout(() => {
  232. that.updateOrder({
  233. "sa_orderid": this.data.sa_orderid, //订单ID
  234. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  235. "sa_contractid": this.data.contacts.contactsid, //合同ID
  236. "type": this.data.type, //订单类型
  237. "items": [{
  238. "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
  239. "itemid": val.itemid, //商品ID
  240. "qty": val.qty, //数量
  241. "needdate": val.needdate//可以不传,修改交期
  242. }]
  243. })
  244. this.$emit("qtyChange")
  245. },500)
  246. },
  247. onDateChange (val){
  248. let that = this
  249. that.value2 = ''
  250. that.updateOrder({
  251. "sa_orderid": this.data.sa_orderid, //订单ID
  252. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  253. "sa_contractid": this.data.contacts.contactsid, //合同ID
  254. "type": this.data.type, //订单类型
  255. "items": [{
  256. "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
  257. "itemid": val.itemid, //商品ID
  258. "qty": val.qty, //数量
  259. "needdate": val.needdate//可以不传,修改交期
  260. }]
  261. })
  262. },
  263. async dateChange (row) {
  264. this.tableData = this.tableData.filter(e=>{
  265. if (e.delivery > 0) {
  266. e.needdate = this.value2
  267. }
  268. return e
  269. })
  270. const res = await this.$api.requested({
  271. "id": 20230104143802,
  272. "content": {
  273. "sa_orderid": this.$route.query.id,
  274. "needdate": this.value2
  275. },
  276. })
  277. },
  278. async updateOrder (val) {
  279. const res = await this.$api.requested({
  280. "id": 20221109093602,
  281. "content": val
  282. })
  283. this.$emit('onSuccess')
  284. },
  285. setPickerOptions (val) {
  286. var startDate = val.deliverydate
  287. startDate = startDate.replace(new RegExp("-","gm"),"/")
  288. var startDateM = (new Date(startDate)).getTime()
  289. this.pickerOptions = {
  290. disabledDate(time) {
  291. return time.getTime() < startDateM;
  292. },
  293. }
  294. },
  295. // 订单添加商品
  296. async onConfirm (data) {
  297. const res = await this.$api.requested({
  298. "id": 20221109093602,
  299. "content": {
  300. "sa_orderid": this.$route.query.id, //订单ID
  301. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  302. "type": this.data.type, //订单类型
  303. "items": data.map(e=>{
  304. return {
  305. sa_orderitemsid:0,
  306. itemid:e.itemid,
  307. qty:e.orderminqty,
  308. needdate:e.deliverydate
  309. }
  310. })
  311. },
  312. })
  313. this.tool.showMessage(res,()=>{
  314. this.setcol = 24
  315. this.listData()
  316. this.$emit('onSuccess')
  317. })
  318. },
  319. },
  320. mounted () {
  321. this.listData()
  322. },
  323. watch:{
  324. value2 (val) {
  325. console.log(val)
  326. }
  327. }
  328. }
  329. </script>
  330. <style>
  331. </style>