toolList.vue 11 KB

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