productlist.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <el-row :gutter="10">
  3. <el-col :span="setcol">
  4. <div class="flex-align-center normal-margin">
  5. <slot name="operation"></slot>
  6. <el-button v-if="data.status === '新建'" class="inline-16" :disabled="data.type === '特殊订单'" size="small" type="primary" @click="drawer = true">{{setcol === 24?'添 加':'取 消'}}</el-button>
  7. <excel class="inline-16" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
  8. </div>
  9. <p v-if="data.status === '新建'" class="normal-margin" style="font-size: 13px !important;color:red;font-weight: normal">{{checkFreefreightamount}}</p>
  10. <el-table
  11. ref="multipleTable"
  12. :data="tableData"
  13. height="500px"
  14. style="width: 100%;"
  15. max-height="410px"
  16. size="small"
  17. stripe
  18. border>
  19. <!-- <el-table-column
  20. type="selection"
  21. width="55"
  22. align="center">
  23. </el-table-column> -->
  24. <el-table-column
  25. prop="rowno"
  26. label="行号"
  27. fixed
  28. width="50">
  29. </el-table-column>
  30. <el-table-column
  31. prop="itemname"
  32. label="产品名称"
  33. fixed
  34. width="180">
  35. </el-table-column>
  36. <el-table-column
  37. prop="itemno"
  38. label="产品编号"
  39. width="180">
  40. </el-table-column>
  41. <el-table-column
  42. prop="erpitemno"
  43. label="erp编号"
  44. width="180">
  45. </el-table-column>
  46. <el-table-column
  47. label="型号"
  48. prop="model">
  49. <template slot-scope="scope">
  50. <p><span>{{scope.row.model}}</span></p>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. label="规格"
  55. prop="spec">
  56. <template slot-scope="scope">
  57. <p><span>{{scope.row.spec}}</span></p>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. label="数量"
  62. width="180"
  63. prop="qty">
  64. <template slot-scope="scope">
  65. <el-input-number
  66. :controls="true" controls-position='right'
  67. :step-strictly="true" v-if="data.status === '新建'"
  68. 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>
  69. <span v-else>{{scope.row.qty}}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column
  73. prop="marketprice"
  74. label="牌价"
  75. width="100">
  76. <template slot-scope="scope">
  77. <p>¥&nbsp;{{tool.formatAmount(scope.row.marketprice,2)}}</p>
  78. </template>
  79. </el-table-column>
  80. <el-table-column
  81. prop="defaultprice"
  82. label="折前价格"
  83. width="100">
  84. <template slot-scope="scope">
  85. <p>¥&nbsp;{{tool.formatAmount(scope.row.defaultprice,2)}}</p>
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. prop="defaultamount"
  90. label="折前金额"
  91. width="100">
  92. <template slot-scope="scope">
  93. <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.defaultprice * scope.row.qty,2)}}</p>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. label="折后单价"
  98. prop="price">
  99. <template slot-scope="scope">
  100. <p>¥&nbsp;{{tool.formatAmount(scope.row.price,2)}}</p>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. label="折后金额"
  105. width="150"
  106. prop="amount">
  107. <template slot-scope="scope">
  108. <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.amount,2)}}</p>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. label="需求日期"
  113. prop="needdate"
  114. width="200">
  115. <template slot="header" slot-scope="scope">
  116. <div>
  117. <el-date-picker
  118. style="width:180px"
  119. v-if="data.status === '新建'"
  120. v-model="value2"
  121. value-format="yyyy-MM-dd"
  122. slot="reference"
  123. align="right"
  124. type="date"
  125. size="mini"
  126. placeholder="一键交期"
  127. @change="dateChange(scope.row)">
  128. </el-date-picker>
  129. <span v-else>需求日期</span>
  130. </div>
  131. </template>
  132. <template slot-scope="scope">
  133. <el-date-picker
  134. v-if="scope.row.delivery > 0 && data.status === '新建'"
  135. v-model="scope.row.needdate"
  136. type="date"
  137. placeholder="选择日期"
  138. value-format="yyyy-MM-dd"
  139. size="mini"
  140. style="width:150px"
  141. :picker-options="pickerOptions"
  142. @change="onDateChange(scope.row)"
  143. @focus="setPickerOptions(scope.row)">
  144. </el-date-picker>
  145. <div v-else>
  146. <p v-if="scope.row.delivery === 0 ">不管控交期</p>
  147. <p v-else>{{scope.row.needdate}}</p>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column
  152. prop="deliverydate"
  153. label="回复交期"
  154. width="120">
  155. </el-table-column>
  156. <el-table-column
  157. prop="unit"
  158. label="计量单位"
  159. width="90">
  160. <template slot-scope="scope">
  161. <el-tag size="mini" type="info" effect="plain">{{scope.row.unit}}</el-tag>
  162. </template>
  163. </el-table-column>
  164. <el-table-column
  165. prop="undeliqty"
  166. label="未发货数量"
  167. width="100">
  168. </el-table-column>
  169. <el-table-column
  170. prop="stockstatus"
  171. label="库存状态"
  172. width="100">
  173. </el-table-column>
  174. <el-table-column
  175. prop="material"
  176. label="材质"
  177. width="100">
  178. </el-table-column>
  179. <el-table-column
  180. prop="prodline"
  181. label="产线"
  182. width="100">
  183. </el-table-column>
  184. <el-table-column
  185. prop="device"
  186. label="装置"
  187. width="100">
  188. </el-table-column>
  189. <el-table-column
  190. prop="specalnote"
  191. label="特殊说明"
  192. width="100">
  193. </el-table-column>
  194. <el-table-column
  195. prop="remarks"
  196. label="备注"
  197. width="300"
  198. fixed="right">
  199. <template slot-scope="scope">
  200. <el-input type="textarea" :disabled="data.status != '新建'" @blur="onConfirm([scope.row],true)" size="small" v-model="scope.row.remarks" placeholder="请输入备注"></el-input>
  201. </template>
  202. </el-table-column>
  203. <el-table-column v-if="data.status === '新建'" width="90" fixed="right">
  204. <template slot-scope="scope">
  205. <el-button type="text" size="mini" @click="deleteOrderProduct(scope.row)">删 除</el-button>
  206. </template>
  207. </el-table-column>
  208. </el-table>
  209. <div style="margin-top:16px;text-align:right">
  210. <el-pagination
  211. background
  212. small
  213. @size-change="handleSizeChange"
  214. @current-change="handleCurrentChange"
  215. :current-page="currentPage"
  216. :page-size="param.content.pageSize"
  217. layout="total, prev, pager, next, jumper"
  218. :total="total">
  219. </el-pagination>
  220. </div>
  221. </el-col>
  222. <el-col :span="24 - setcol">
  223. <el-drawer
  224. title="添加商品"
  225. :visible.sync="drawer"
  226. append-to-body
  227. direction="rtl"
  228. size="80%">
  229. <div class="drawer__panel">
  230. <addProduct :drawer="drawer" :data="data" @onConfirm="onConfirm"></addProduct>
  231. </div>
  232. </el-drawer>
  233. </el-col>
  234. </el-row>
  235. </template>
  236. <script>
  237. import addProduct from '@/template/orderCanUseProduct/index.vue'
  238. export default {
  239. props:['data','type'],
  240. data () {
  241. return {
  242. freefreightamount:null,
  243. drawer:false,
  244. setcol:24,
  245. dataRefresh:true,
  246. tableData:[],
  247. columnTitle:[],
  248. excelTitle:'订单明细',
  249. param:{
  250. "id": 20221109093902,
  251. "content": {
  252. "sa_orderid": 0, //订单ID
  253. "pageNumber": 1,
  254. "pageSize": 9999,
  255. "where": {
  256. "condition": ""
  257. }
  258. },
  259. },
  260. pickerOptions: {
  261. disabledDate(time) {
  262. return time.getTime() < (Date.now() - 24 * 3600 * 1000);
  263. },
  264. },
  265. total:0,
  266. currentPage:0,
  267. time: null,
  268. value2:''
  269. }
  270. },
  271. computed:{
  272. checkFreefreightamount () {
  273. let result = ''
  274. switch (this.freefreightamount) {
  275. case -1:
  276. result = '不免运费'
  277. break;
  278. case 0:
  279. result = '免运费'
  280. break;
  281. default:
  282. result = this.data.amount >= this.freefreightamount?'当前订单免运费':`订单满${this.tool.formatAmount(this.freefreightamount,2)}元免运费,当前还差${this.tool.formatAmount(this.freefreightamount - this.data.amount,2)}元`
  283. break;
  284. }
  285. return result
  286. },
  287. },
  288. components:{
  289. /*excel:() => import('../export_excel'),*/
  290. excel:() => import('../details/export_excel'),
  291. addProduct
  292. },
  293. methods:{
  294. async listData () {
  295. this.param.content.sa_orderid = this.$route.query.id
  296. const res = await this.$api.requested(this.param)
  297. this.tableData = res.data
  298. this.total = res.total
  299. this.currentPage = res.pageNumber
  300. this.queryBasicInfo()
  301. },
  302. handleSizeChange(val) {
  303. // console.log(`每页 ${val} 条`);
  304. this.params.content.pageSize = val
  305. this.listData()
  306. },
  307. handleCurrentChange(val) {
  308. // console.log(`当前页: ${val}`);
  309. this.params.content.pageNumber = val
  310. this.listData()
  311. },
  312. async deleteOrderProduct (row) {
  313. const res = await this.$api.requested({
  314. "id": 20221109093702,
  315. "content": {
  316. "sa_orderid":this.$route.query.id,
  317. "sa_orderitemsids": [row.sa_orderitemsid]
  318. },
  319. })
  320. this.tool.showMessage(res,()=>{
  321. this.listData()
  322. this.$emit('onSuccess')
  323. })
  324. },
  325. // async updateOrderProduct (val) {
  326. // const res = await this.$api.requested({
  327. // "id": 20221110145302,
  328. // "content": val
  329. // })
  330. // this.$emit('onSuccess')
  331. // },
  332. qtyChange (val,index) {
  333. let that = this
  334. this.$set(this.tableData,index,val)
  335. // // 防抖
  336. if(this.time !== null){
  337. clearTimeout(this.time);
  338. }
  339. this.time = setTimeout(() => {
  340. that.updateOrder({
  341. "sa_orderid": this.data.sa_orderid, //订单ID
  342. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  343. "sa_contractid": this.data.contacts.contactsid, //合同ID
  344. "type": this.data.type, //订单类型
  345. "items": this.tableData
  346. })
  347. this.$emit("qtyChange")
  348. },500)
  349. },
  350. onDateChange (val){
  351. let that = this
  352. that.value2 = ''
  353. that.updateOrder({
  354. "sa_orderid": this.data.sa_orderid, //订单ID
  355. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  356. "sa_contractid": this.data.contacts.contactsid, //合同ID
  357. "type": this.data.type, //订单类型
  358. "items": this.tableData
  359. })
  360. },
  361. async dateChange (row) {
  362. this.tableData = this.tableData.filter(e=>{
  363. if (e.delivery > 0) {
  364. e.needdate = this.value2
  365. }
  366. return e
  367. })
  368. const res = await this.$api.requested({
  369. "id": 20230104143802,
  370. "content": {
  371. "sa_orderid": this.$route.query.id,
  372. "needdate": this.value2
  373. },
  374. })
  375. },
  376. async updateOrder (val) {
  377. const res = await this.$api.requested({
  378. "id": 20221109093602,
  379. "content": val
  380. })
  381. if (res.code == 1) {
  382. this.$emit('onSuccess')
  383. } else {
  384. this.$message({
  385. message:res.data + ':' + res.msg,
  386. type:'error'
  387. })
  388. this.listData()
  389. }
  390. },
  391. setPickerOptions (val) {
  392. var startDate = val.deliverydate
  393. startDate = startDate.replace(new RegExp("-","gm"),"/")
  394. var startDateM = (new Date(startDate)).getTime()
  395. this.pickerOptions = {
  396. disabledDate(time) {
  397. return time.getTime() < startDateM;
  398. },
  399. }
  400. },
  401. // 订单添加商品
  402. async onConfirm (data,edit) {
  403. const res = await this.$api.requested({
  404. "id": 20221109093602,
  405. "content": {
  406. "sa_orderid": this.$route.query.id, //订单ID
  407. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  408. "type": this.data.type, //订单类型
  409. "items": data.map(e=>{
  410. return {
  411. sa_orderitemsid:edit?e.sa_orderitemsid : 0,
  412. itemid:e.itemid,
  413. qty:e.orderminqty,
  414. needdate:e.deliverydate,
  415. remarks:e.remarks
  416. }
  417. })
  418. },
  419. })
  420. this.tool.showMessage(res,()=>{
  421. this.drawer = false
  422. this.listData()
  423. this.$emit('onSuccess')
  424. })
  425. },
  426. async queryBasicInfo () {
  427. const res = await this.$api.requested({
  428. "id":20220920084001,"content":{
  429. sys_enterpriseid:this.data.sys_enterpriseid
  430. },
  431. })
  432. this.freefreightamount = res.data.freefreightamount?res.data.freefreightamount:0
  433. }
  434. },
  435. mounted () {
  436. this.listData()
  437. console.log("表结构")
  438. this.columnTitle = []
  439. this.$refs.multipleTable.$children.forEach(obj => {
  440. let columnChild = {'columnname':obj.prop,'filter':0,'rowindex':'','sequence':'','title':obj.label,'width':obj.width}
  441. // 存到columnTitle数组中
  442. this.columnTitle.push(columnChild)
  443. })
  444. // console.log(this.columnTitle)
  445. },
  446. watch:{
  447. value2 (val) {
  448. console.log(val)
  449. }
  450. }
  451. }
  452. </script>
  453. <style>
  454. </style>