toolList.vue 9.6 KB

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