attachmentSalesOrderDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div class="s-page">
  3. <el-page-header @back="goBack" :content="title"></el-page-header>
  4. <el-divider></el-divider>
  5. <el-card class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>单据信息</span>
  8. </div>
  9. <div class="mymain-container">
  10. <el-form ref="formData" :rules="rules" :model="formData" label-width="110px" size="small" label-position="left">
  11. <el-row :gutter="20" justify="start">
  12. <el-col :span="8" v-if="id">
  13. <el-form-item label="单据状态">
  14. <el-input type="text" :value="formData.flag == 'SAVE'?'已保存':formData.flag == 'SUBMIT'?'已提交':formData.flag == 'CANCEL'?'取消订单':formData.flag == 'PAY_NOT_TAKE'?'已支付,未提货':formData.flag == 'PAY_TAKE'?'已支付,已提货':''" disabled></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="8" v-if="id">
  18. <el-form-item label="单据编号">
  19. <el-input type="text" :value="formData.salesId" disabled></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label="所属商户" :required="true" >
  24. <el-input type="text" :value="companyName" disabled></el-input>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="12">
  28. <el-form-item label="网点名称" prop="websitId" :required="true">
  29. <el-select v-model="formData.websit" :disabled="formType == 2" value-key="websitId" @change="changeWebsit" placeholder="请选择" style="width: 100%;">
  30. <el-option
  31. v-for="item in websitList"
  32. :key="item.websitId"
  33. :label="item.name"
  34. :value="item">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="师傅姓名" prop="worker" :required="true">
  41. <el-select v-model="formData.worker" :disabled="formType == 2" value-key="nickName" @focus="()=>{
  42. if(!this.formData.websitId){return this.$message.warning('请先选择网点名称!');}
  43. }" filterable @change="changeWorker" @blur="workerBlur" placeholder="请选择" style="width: 100%;">
  44. <el-option
  45. v-for="item in workerList"
  46. :key="item.id"
  47. :label="item.nickName"
  48. :value="item">
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="师傅身份证" prop="identity" :required="true">
  55. <el-input type="text" v-model="formData.identity" :disabled="formType == 2" placeholder="请输入"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="师傅联系电话" prop="workerMobile" :required="true">
  60. <el-input type="text" v-model="formData.workerMobile" :disabled="formType == 2" placeholder="请输入"></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="6" v-if="id">
  64. <el-form-item label="单据金额">
  65. <el-input type="text" :value="formData.totalAmount" disabled></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="6" v-if="id">
  69. <el-form-item label="制单人">
  70. <el-input type="text" :value="formData.createBy" disabled></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6" v-if="id">
  74. <el-form-item label="制单时间">
  75. <el-input type="text" :value="formData.createTime" disabled></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6" v-if="id">
  79. <el-form-item label="审核人">
  80. <el-input type="text" :value="formData.confirmBy" disabled></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="6" v-if="id">
  84. <el-form-item label="审核时间">
  85. <el-input type="text" :value="formData.confirmTime" disabled></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="12">
  89. <el-form-item label="订单来源" prop="source" :required="true">
  90. <el-select v-model="formData.source" :disabled="formType == 2" placeholder="请选择" style="width: 100%;">
  91. <!-- v-for="item in [{name: '在线订单',id: 'ONLINE'},{name: '自建订单',id: 'SELF'}]" -->
  92. <el-option
  93. v-for="item in [{name: '自建订单',id: 'SELF'}]"
  94. :key="item.id"
  95. :label="item.name"
  96. :value="item.id">
  97. </el-option>
  98. </el-select>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="9">
  102. <el-form-item label="支付方式" prop="payType" :required="true">
  103. <el-select v-model="formData.payType" :disabled="formType == 2" placeholder="请选择" style="width: 100%;">
  104. <el-option
  105. v-for="item in [{name: '现金',id: 'CASH'},{name: '微信',id: 'WECHAT'}]"
  106. :key="item.id"
  107. :label="item.name"
  108. :value="item.id">
  109. </el-option>
  110. </el-select>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="3" v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'">
  114. <div style="height: 32px;display: flex;align-items: center;cursor: pointer;" @click="wxPay()">微信支付<i class="el-icon-full-screen"></i></div>
  115. </el-col>
  116. <el-col :span="24">
  117. <el-form-item label="备注">
  118. <el-input type="textarea" :rows="4" v-model="formData.remark" :disabled="formType == 2" placeholder="请输入"></el-input>
  119. </el-form-item>
  120. </el-col>
  121. </el-row>
  122. </el-form>
  123. </div>
  124. </el-card>
  125. <el-card class="box-card">
  126. <div slot="header" class="clearfix">
  127. <span>配件信息</span>
  128. </div>
  129. <el-button size="small" v-if="formData.flag == 'SAVE' || formType==0" type="primary" @click="add()">添加</el-button>
  130. <div class="table">
  131. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  132. <el-table-column label="配件名称" align="center">
  133. <template slot-scope="scope">
  134. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  135. <el-option
  136. v-for="item in scope.row.goodsList"
  137. :key="item.goodsId"
  138. :label="item.goodsName"
  139. :value="item">
  140. </el-option>
  141. </el-select>
  142. </template>
  143. </el-table-column>
  144. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  145. <el-table-column prop="" align="center" label="数量" >
  146. <template slot-scope="scope">
  147. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="goods.goodsCode" align="center" label="配件编码"></el-table-column>
  151. <el-table-column prop="goods.brandRelaName" align="center" label="适用品牌"></el-table-column>
  152. <el-table-column prop="goods.productRelaName" align="center" label="适用产品大类"></el-table-column>
  153. <el-table-column prop="goods.price" align="center" label="销售价格"></el-table-column>
  154. <el-table-column prop="goods.saleAmount" align="center" label="销售金额" >
  155. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.goods && scope.row.goods.price">
  156. {{(scope.row.goods.price * 100) * scope.row.salesQty / 100}}
  157. </template>
  158. </el-table-column>
  159. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  160. <el-table-column label="操作" align="right" width="140">
  161. <template slot-scope="scope" v-if="formType != 2">
  162. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  163. <el-button size="mini" type="danger" @click="dataList.splice(scope.$index,1)">删除</el-button>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. </div>
  168. </el-card>
  169. <div class="page-footer">
  170. <div class="footer">
  171. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  172. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  173. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认收货</el-button>
  174. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  175. <el-button size="small" type="info" @click="goBack">返回</el-button>
  176. </div>
  177. </div>
  178. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  179. <h3 style="text-align: center;">扫二维码支付</h3>
  180. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  181. <div
  182. ref="payQRCode"
  183. style="display: flex; justify-content: center;"
  184. />
  185. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  186. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  187. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  188. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  189. </div>
  190. </el-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import { getWebsit } from "@/api/customerManagement";
  195. import QRCode from "qrcodejs2";
  196. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  197. export default {
  198. props: ['id','title','formType'],
  199. data() {
  200. return {
  201. dataList: [],
  202. websitList: [],
  203. workerList: [],
  204. isPay: false,
  205. is_submit: true,
  206. payCodeUrl: '',
  207. formData: {
  208. websit: {},
  209. websitId: '',
  210. websitName: '',
  211. file_url: [],
  212. salesId: '',
  213. flag: '',
  214. createBy: '',
  215. createTime: '',
  216. confirmBy: '',
  217. confirmTime: '',
  218. worker: {},
  219. workerName: '',
  220. workerId: '',
  221. identity: '',
  222. workerMobile: '',
  223. source: '',
  224. payType: '',
  225. totalAmount: '',
  226. remark: ''
  227. },
  228. isEdit: 0,
  229. timer: '',
  230. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  231. rules: {
  232. websitId: [
  233. { required: true, message: '请选择网点', trigger: 'change' }
  234. ],
  235. worker: [
  236. { required: true, message: '请选择师傅', trigger: 'change' }
  237. ],
  238. source: [
  239. { required: true, message: '请选择订单来源', trigger: 'change' }
  240. ],
  241. payType: [
  242. { required: true, message: '请选择订单来源', trigger: 'change' }
  243. ],
  244. identity: [
  245. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  246. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  247. ],
  248. workerMobile: [
  249. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  250. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  251. ],
  252. }
  253. };
  254. },
  255. computed: {},
  256. created() {
  257. if(this.id){
  258. this.getDetail()
  259. }
  260. this.getWebsit()
  261. },
  262. methods: {
  263. // 返回
  264. goBack() {
  265. this.$emit('back');
  266. },
  267. async getDetail(){
  268. const that = this
  269. getDetail({salesId: this.id}).then(async res => {
  270. Object.assign(this.formData, res.data, {
  271. websit: {websitId: res.data.websitId,name: res.data.websitName},
  272. worker: {nickName: res.data.workerName,userId: res.data.workerId}
  273. })
  274. this.getWorker()
  275. for(var item of res.data.items){
  276. var ress = await that.getGoods(item.goodsName, 1)
  277. item.goods = {...ress.data,oldPrice:ress.data.price}
  278. item.goodsList = ress.data ? [{...ress.data,oldPrice:ress.data.price}] : []
  279. }
  280. this.dataList = res.data.items
  281. })
  282. },
  283. getWebsit(){
  284. getWebsit({type: 'C'}).then(res => {
  285. this.websitList = res.data
  286. })
  287. },
  288. changeWebsit(e){
  289. this.formData.websitId = e.websitId
  290. this.formData.websitName = e.name
  291. this.getWorker()
  292. },
  293. async getGoods(goodsName,type){
  294. const that = this
  295. if(type == 1){
  296. return new Promise((resolve, reject) => {
  297. getGoods({websitId: this.formData.websitId,type: 'P',goodsName: goodsName}).then(res => {
  298. resolve({
  299. data: res.data[0]
  300. })
  301. })
  302. })
  303. }else{
  304. getGoods({websitId: this.formData.websitId,type: 'P'}).then(res => {
  305. that.dataList[that.isEdit].goodsList = res.data
  306. console.log(this.dataList)
  307. })
  308. }
  309. },
  310. getWorker(){
  311. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  312. this.workerList = res.data.records
  313. })
  314. },
  315. changeWorker(e){
  316. this.formData.identity = e.idCard
  317. this.formData.workerMobile = e.mobile
  318. this.formData.workerId = e.userId
  319. this.formData.workerName = e.nickName
  320. },
  321. workerBlur(e){
  322. this.formData.worker = e.target.value
  323. this.$forceUpdate()
  324. },
  325. changeGoods(e){
  326. console.log(e)
  327. this.dataList[this.isEdit].goodsId = e.goodsId
  328. this.dataList[this.isEdit].goodsName = e.goodsName
  329. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  330. this.dataList[this.isEdit].brandRelaName = e.brandRelaName
  331. this.dataList[this.isEdit].productRelaName = e.productRelaName
  332. this.dataList[this.isEdit].price = e.price
  333. this.dataList[this.isEdit].goodsCode = e. goodsCode
  334. this.dataList[this.isEdit].qty = e.qty
  335. },
  336. add(){
  337. if(this.dataList.length != 0){this.isEdit += 1}
  338. this.dataList.push({
  339. goodsList: [],
  340. goods: {},
  341. goodsId: '',
  342. goodsName: '',
  343. goodsSalesUnit: '',
  344. brandRelaName: '',
  345. productRelaName: '',
  346. goodsCode: '',
  347. price: '',
  348. saleAmount: '',
  349. salesQty: 1,
  350. qty: '',
  351. goodsType: 'P'
  352. })
  353. this.getGoods()
  354. },
  355. submit(){
  356. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  357. confirmButtonText: '确定',
  358. cancelButtonText: '取消',
  359. type: 'warning'
  360. }).then(() => {
  361. submit({
  362. salesId: this.formData.salesId
  363. }).then(res => {
  364. if(res.code == 200){
  365. this.$message.success('提交成功!')
  366. if(this.formData.payType == 'WECHAT'){
  367. this.wxPay()
  368. }else{
  369. this.goBack()
  370. }
  371. }
  372. })
  373. });
  374. },
  375. confirm(){
  376. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  377. confirmButtonText: '确定',
  378. cancelButtonText: '取消',
  379. type: 'warning'
  380. }).then(() => {
  381. confirm({
  382. salesId: this.formData.salesId
  383. }).then(res => {
  384. if(res.code == 200){
  385. this.$message.success('审核成功!')
  386. this.goBack()
  387. }
  388. })
  389. });
  390. },
  391. checkPay(){
  392. this.timer = setInterval(()=>{
  393. getDetail({salesId: this.id}).then(res => {
  394. if(res.data.payFlag == 'YES'){
  395. this.clear()
  396. this.$message.success('支付成功!')
  397. this.goBack()
  398. }
  399. })
  400. },3000)
  401. },
  402. clear(){
  403. clearInterval(this.timer)
  404. },
  405. wxPay(){
  406. if(!this.is_submit){
  407. return false
  408. }
  409. this.is_submit = false
  410. setTimeout(()=>{
  411. this.is_submit = true
  412. },3000)
  413. getCode({
  414. salesId: this.formData.salesId
  415. }).then(res => {
  416. if(res.code == 200){
  417. this.payCodeUrl = res.data.codeUrl
  418. this.isPay = true
  419. this.$nextTick(() => {
  420. this.payUrl = res.data.codeUrl;
  421. new QRCode(this.$refs.payQRCode, {
  422. text: res.data.codeUrl,
  423. width: 200,
  424. height: 200,
  425. colorDark: "#333333", // 二维码颜色
  426. colorLight: "#ffffff", // 二维码背景色
  427. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  428. });
  429. this.checkPay()
  430. });
  431. }
  432. })
  433. },
  434. save(){
  435. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  436. if (valid) {
  437. if(this.formType == 0){
  438. add({
  439. goodsType: 'P',
  440. source: this.formData.source,
  441. payType: this.formData.payType,
  442. remark: this.formData.remark,
  443. websitId: this.formData.websitId,
  444. websitName: this.formData.websitName,
  445. workerName: this.formData.workerName,
  446. workerId: this.formData.workerId,
  447. identity: this.formData.identity,
  448. workerMobile: this.formData.workerMobile,
  449. items: this.dataList
  450. }).then(res => {
  451. if(res.code == 200){
  452. this.$message.success('提交成功!')
  453. this.goBack()
  454. }
  455. })
  456. }else if(this.formType == 1){
  457. edit({
  458. salesId: this.formData.salesId,
  459. goodsType: 'P',
  460. source: this.formData.source,
  461. payType: this.formData.payType,
  462. remark: this.formData.remark,
  463. websitId: this.formData.websitId,
  464. websitName: this.formData.websitName,
  465. workerName: this.formData.workerName,
  466. workerId: this.formData.workerId,
  467. identity: this.formData.identity,
  468. workerMobile: this.formData.workerMobile,
  469. items: this.dataList
  470. }).then(res => {
  471. if(res.code == 200){
  472. this.dataList = []
  473. this.$message.success('提交成功!')
  474. this.goBack()
  475. }
  476. })
  477. }
  478. }
  479. })
  480. }
  481. }
  482. };
  483. </script>
  484. <style scoped="scoped" lang="scss">
  485. .s-page {
  486. padding: 20px;
  487. background-color: #ffffff;
  488. }
  489. .page-footer {
  490. height: 70px;
  491. }
  492. .footer {
  493. position: fixed;
  494. bottom: 0;
  495. left: 0;
  496. z-index: 1;
  497. width: 100%;
  498. background: #fff;
  499. padding: 15px 40px;
  500. box-sizing: border-box;
  501. transition: all 0.28s;
  502. text-align: right;
  503. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  504. &.hideSidebar {
  505. margin-left: 54px;
  506. width: calc(100vw - 54px);
  507. }
  508. &.openSidebar {
  509. margin-left: 210px;
  510. width: calc(100vw - 210px);
  511. }
  512. .tips {
  513. font-size: 12px;
  514. color: red;
  515. margin-top: 10px;
  516. }
  517. }
  518. </style>