productlist.vue 14 KB

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