auxiliarySalesOrderDetail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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 == 'OK'?'审核通过':formData.flag == 'OK'?'FAIL':''" 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" 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" 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="idcard" :required="true">
  55. <el-input type="text" v-model="formData.idcard" placeholder="请输入"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="师傅联系电话" prop="phone" :required="true">
  60. <el-input type="text" v-model="formData.phone" 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.createBy" 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" placeholder="请选择" style="width: 100%;">
  91. <el-option
  92. v-for="item in [{name: '在线订单',id: 'ONLINE'},{name: '自建订单',id: 'SELF'}]"
  93. :key="item.id"
  94. :label="item.name"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="9">
  101. <el-form-item label="支付方式" prop="payType" :required="true">
  102. <el-select v-model="formData.payType" placeholder="请选择" style="width: 100%;">
  103. <el-option
  104. v-for="item in [{name: '现金',id: 'CASH'},{name: '微信',id: 'WECHAT'}]"
  105. :key="item.id"
  106. :label="item.name"
  107. :value="item.id">
  108. </el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="3" v-if="formData.payType == 'WECHAT'">
  113. <div style="height: 32px;display: flex;align-items: center;cursor: pointer;">微信支付<i class="el-icon-full-screen"></i></div>
  114. </el-col>
  115. <el-col :span="24">
  116. <el-form-item label="备注">
  117. <el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入"></el-input>
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </el-form>
  122. </div>
  123. </el-card>
  124. <el-card class="box-card">
  125. <div slot="header" class="clearfix">
  126. <span>辅材信息</span>
  127. </div>
  128. <el-button size="small" type="primary" @click="add()">添加</el-button>
  129. <div class="table">
  130. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  131. <el-table-column label="大类名称" align="center">
  132. <template slot-scope="scope">
  133. <el-select v-model="scope.row.parentCategory" value-key="categoryId" @change="changeMain" :disabled="isEdit != scope.$index" placeholder="请选择" style="width: 100%;">
  134. <el-option
  135. v-for="item in mainList"
  136. :key="item.categoryId"
  137. :label="item.categoryName"
  138. :value="item">
  139. </el-option>
  140. </el-select>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="小类名称" align="center">
  144. <template slot-scope="scope">
  145. <el-select v-model="scope.row.goodsCategory" @change="changeSmall" @focus="()=>{
  146. if(!scope.row.parentCategory){return this.$message.warning('请先选择大类!');}
  147. }" :disabled="isEdit != scope.$index" value-key="categoryId" placeholder="请选择" style="width: 100%;">
  148. <el-option
  149. v-for="item in scope.row.parentCategory.items"
  150. :key="item.categoryId"
  151. :label="item.categoryName"
  152. :value="item">
  153. </el-option>
  154. </el-select>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="辅材名称" align="center">
  158. <template slot-scope="scope">
  159. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index" placeholder="请选择" style="width: 100%;">
  160. <el-option
  161. v-for="item in scope.row.goodsList"
  162. :key="item.goodsId"
  163. :label="item.goodsName"
  164. :value="item">
  165. </el-option>
  166. </el-select>
  167. </template>
  168. </el-table-column>
  169. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  170. <el-table-column prop="" align="center" label="数量" >
  171. <template slot-scope="scope">
  172. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index" placeholder="请输入"></el-input>
  173. </template>
  174. </el-table-column>
  175. <el-table-column prop="goods.goodsCode" align="center" label="商品代码"></el-table-column>
  176. <el-table-column prop="goods.goodsSpecification" align="center" label="规格型号"></el-table-column>
  177. <el-table-column prop="goods.price" align="center" label="销售价格"></el-table-column>
  178. <el-table-column prop="goods.saleAmount" align="center" label="销售金额" ></el-table-column>
  179. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  180. <el-table-column label="操作" align="right" width="140">
  181. <template slot-scope="scope">
  182. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  183. <el-button size="mini" type="danger" @click="dataList.splice(scope.$index,1)">删除</el-button>
  184. </template>
  185. </el-table-column>
  186. </el-table>
  187. </div>
  188. </el-card>
  189. <div class="page-footer">
  190. <div class="footer">
  191. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  192. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  193. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  194. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认收货</el-button>
  195. <el-button size="small" type="info" @click="goBack">返回</el-button>
  196. </div>
  197. </div>
  198. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = ''">
  199. <h3>扫二维码支付</h3>
  200. <el-image :src="payCodeUrl" fit="fit"></el-image>
  201. </el-dialog>
  202. </div>
  203. </template>
  204. <script>
  205. import { getWebsit } from "@/api/customerManagement";
  206. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  207. export default {
  208. props: ['id','title','formType'],
  209. data() {
  210. return {
  211. dataList: [],
  212. websitList: [],
  213. workerList: [],
  214. mainList: [],
  215. isPay: false,
  216. payCodeUrl: '',
  217. formData: {
  218. websit: {},
  219. websitId: '',
  220. websitName: '',
  221. file_url: [],
  222. salesId: '',
  223. flag: '',
  224. createBy: '',
  225. createTime: '',
  226. confirmBy: '',
  227. confirmTime: '',
  228. worker: {},
  229. workerName: '',
  230. workerId: '',
  231. idcard: '',
  232. phone: '',
  233. source: '',
  234. payType: ''
  235. },
  236. isEdit: 0,
  237. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  238. rules: {
  239. websitId: [
  240. { required: true, message: '请选择网点', trigger: 'change' }
  241. ],
  242. worker: [
  243. { required: true, message: '请选择师傅', trigger: 'change' }
  244. ],
  245. source: [
  246. { required: true, message: '请选择订单来源', trigger: 'change' }
  247. ],
  248. payType: [
  249. { required: true, message: '请选择订单来源', trigger: 'change' }
  250. ],
  251. idcard: [
  252. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  253. ],
  254. phone: [
  255. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  256. ],
  257. }
  258. };
  259. },
  260. computed: {},
  261. created() {
  262. if(this.id){
  263. this.getDetail()
  264. }
  265. this.getWebsit()
  266. },
  267. methods: {
  268. // 返回
  269. goBack() {
  270. this.$emit('back');
  271. },
  272. async getDetail(){
  273. const that = this
  274. getDetail({salesId: this.id}).then(res => {
  275. this.formData.flag = res.data.flag
  276. this.formData.websit = {websitId: res.data.websitId,name: res.data.websitName}
  277. this.formData.websitId = res.data.websitId
  278. this.formData.websitName = res.data.websitName
  279. this.getWorker()
  280. this.formData.salesId = res.data.salesId
  281. this.formData.createBy = res.data.createBy
  282. this.formData.createTime = res.data.createTime
  283. this.formData.confirmBy = res.data.confirmBy
  284. this.formData.confirmTime = res.data.confirmTime
  285. this.formData.worker = {nickName: res.data.workerName,userId: res.data.workerId}
  286. this.formData.workerName = res.data.workerName
  287. this.formData.workerId = res.data.workerId
  288. this.formData.idcard = res.data.identity
  289. this.formData.phone = res.data.workerMobile
  290. this.formData.source = res.data.source
  291. this.formData.payType = res.data.payType
  292. this.getCategory(res.data.websitId)
  293. this.formData.remark = res.data.remark
  294. res.data.items.forEach(item=>{
  295. item.parentCategory = {categoryId: item.parentCategoryId,categoryName: item.parentCategoryName,items: [{categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}]}
  296. item.goodsCategory = {categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}
  297. that.getGoods(item.goodsCategoryId,item.goodsName,1).then(ress => {
  298. item.goods = {...ress.data,oldPrice:ress.data.price}
  299. item.goodsList = [{...ress.data,oldPrice:ress.data.price}]
  300. })
  301. })
  302. setTimeout(()=>{
  303. this.dataList = res.data.items
  304. },200)
  305. console.log(this.dataList)
  306. })
  307. },
  308. getWebsit(){
  309. getWebsit({type: 'C'}).then(res => {
  310. this.websitList = res.data
  311. })
  312. },
  313. changeWebsit(e){
  314. this.formData.websitId = e.websitId
  315. this.formData.websitName = e.name
  316. this.getWorker()
  317. this.getCategory(e.websitId)
  318. },
  319. getCategory(websitId){
  320. getCategory({websitId}).then(res => {
  321. this.mainList = res.data
  322. })
  323. },
  324. async getGoods(categoryId,goodsName,type){
  325. const that = this
  326. if(type == 1){
  327. return new Promise((resolve, reject) => {
  328. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M',goodsName: goodsName}).then(res => {
  329. resolve({
  330. data: res.data[0]
  331. })
  332. })
  333. })
  334. }else{
  335. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M'}).then(res => {
  336. that.dataList[that.isEdit].goodsList = res.data
  337. })
  338. }
  339. },
  340. getWorker(){
  341. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  342. this.workerList = res.data.records
  343. })
  344. },
  345. changeWorker(e){
  346. this.formData.idcard = e.idCard
  347. this.formData.phone = e.mobile
  348. this.formData.workerId = e.userId
  349. this.formData.workerName = e.nickName
  350. },
  351. workerBlur(e){
  352. this.formData.worker = e.target.value
  353. this.$forceUpdate()
  354. },
  355. changeMain(e){
  356. this.dataList[this.isEdit].goodsList = [],
  357. this.dataList[this.isEdit].parentCategory = e,
  358. this.dataList[this.isEdit].parentCategoryId = e.categoryId,
  359. this.dataList[this.isEdit].parentCategoryName = e.categoryName,
  360. this.dataList[this.isEdit].goodsCategory = {},
  361. this.dataList[this.isEdit].goodsCategoryName = '',
  362. this.dataList[this.isEdit].goodsCategoryId = '',
  363. this.dataList[this.isEdit].goods = {},
  364. this.dataList[this.isEdit].goodsId = '',
  365. this.dataList[this.isEdit].goodsName = '',
  366. this.dataList[this.isEdit].goodsSalesUnit = '',
  367. this.dataList[this.isEdit].goodsSpecification = '',
  368. this.dataList[this.isEdit].goodsCode = '',
  369. this.dataList[this.isEdit].price = '',
  370. this.dataList[this.isEdit].saleAmount = '',
  371. this.dataList[this.isEdit].salesQty = ''
  372. this.dataList[this.isEdit].qty = '',
  373. this.dataList[this.isEdit].goodsType = 'M'
  374. },
  375. async changeSmall(e){
  376. this.dataList[this.isEdit].goods = {},
  377. this.dataList[this.isEdit].goodsId = '',
  378. this.dataList[this.isEdit].goodsName = '',
  379. this.dataList[this.isEdit].goodsSalesUnit = '',
  380. this.dataList[this.isEdit].goodsSpecification = '',
  381. this.dataList[this.isEdit].goodsCode = '',
  382. this.dataList[this.isEdit].price = '',
  383. this.dataList[this.isEdit].saleAmount = '',
  384. this.dataList[this.isEdit].salesQty = ''
  385. this.dataList[this.isEdit].qty = '',
  386. this.dataList[this.isEdit].goodsCategoryId = e.categoryId
  387. this.dataList[this.isEdit].goodsCategoryName = e.categoryName
  388. getGoods({websitId: this.formData.websitId,categoryId: e.categoryId,type: 'M'}).then(res => {
  389. this.dataList[this.isEdit].goodsList = res.data
  390. })
  391. },
  392. changeGoods(e){
  393. console.log(e)
  394. this.dataList[this.isEdit].goodsId = e.goodsId
  395. this.dataList[this.isEdit].goodsName = e.goodsName
  396. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  397. this.dataList[this.isEdit].goodsSpecification = e.goodsSpecification
  398. this.dataList[this.isEdit].price = e.price
  399. this.dataList[this.isEdit].goodsCode = e. goodsCode
  400. this.dataList[this.isEdit].qty = e.qty
  401. },
  402. add(){
  403. this.dataList.push({
  404. goodsList: [],
  405. parentCategory: {},
  406. parentCategoryId: '',
  407. parentCategoryName: '',
  408. goodsCategory: {},
  409. goodsCategoryName: '',
  410. goodsCategoryId: '',
  411. goods: {},
  412. goodsId: '',
  413. goodsName: '',
  414. goodsSalesUnit: '',
  415. goodsSpecification: '',
  416. goodsCode: '',
  417. price: '',
  418. saleAmount: '',
  419. salesQty: 1,
  420. qty: '',
  421. goodsType: 'M'
  422. })
  423. },
  424. submit(){
  425. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  426. confirmButtonText: '确定',
  427. cancelButtonText: '取消',
  428. type: 'warning'
  429. }).then(() => {
  430. submit({
  431. salesId: this.formData.salesId
  432. }).then(res => {
  433. if(res.code == 200){
  434. this.$message.success('提交成功!')
  435. if(this.formData.payType == 'WECHAT'){
  436. this.isPay = true
  437. }else{
  438. this.goBack()
  439. }
  440. }
  441. })
  442. });
  443. },
  444. confirm(){
  445. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  446. confirmButtonText: '确定',
  447. cancelButtonText: '取消',
  448. type: 'warning'
  449. }).then(() => {
  450. confirm({
  451. salesId: this.formData.salesId
  452. }).then(res => {
  453. if(res.code == 200){
  454. this.$message.success('审核成功!')
  455. this.goBack()
  456. }
  457. })
  458. });
  459. },
  460. wxPay(){
  461. getCode({
  462. salesId: this.formData.salesId
  463. }).then(res => {
  464. if(res.code == 200){
  465. }
  466. })
  467. },
  468. save(){
  469. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  470. if (valid) {
  471. if(this.formType == 0){
  472. add({
  473. goodsType: 'M',
  474. source: this.formData.source,
  475. payType: this.formData.payType,
  476. remark: this.formData.remark,
  477. websitId: this.formData.websitId,
  478. websitName: this.formData.websitName,
  479. workerName: this.formData.workerName,
  480. workerId: this.formData.workerId,
  481. identity: this.formData.idcard,
  482. workerMobile: this.formData.phone,
  483. items: this.dataList
  484. }).then(res => {
  485. if(res.code == 200){
  486. this.$message.success('提交成功!')
  487. this.goBack()
  488. }
  489. })
  490. }else if(this.formType == 1){
  491. edit({
  492. salesId: this.formData.salesId,
  493. goodsType: 'M',
  494. source: this.formData.source,
  495. payType: this.formData.payType,
  496. remark: this.formData.remark,
  497. websitId: this.formData.websitId,
  498. websitName: this.formData.websitName,
  499. workerName: this.formData.workerName,
  500. workerId: this.formData.workerId,
  501. identity: this.formData.idcard,
  502. workerMobile: this.formData.phone,
  503. items: this.dataList
  504. }).then(res => {
  505. if(res.code == 200){
  506. this.dataList = []
  507. this.$message.success('提交成功!')
  508. this.goBack()
  509. }
  510. })
  511. }
  512. }
  513. })
  514. }
  515. }
  516. };
  517. </script>
  518. <style scoped="scoped" lang="scss">
  519. .s-page {
  520. padding: 20px;
  521. background-color: #ffffff;
  522. }
  523. .page-footer {
  524. height: 70px;
  525. }
  526. .footer {
  527. position: fixed;
  528. bottom: 0;
  529. left: 0;
  530. z-index: 1;
  531. width: 100%;
  532. background: #fff;
  533. padding: 15px 40px;
  534. box-sizing: border-box;
  535. transition: all 0.28s;
  536. text-align: right;
  537. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  538. &.hideSidebar {
  539. margin-left: 54px;
  540. width: calc(100vw - 54px);
  541. }
  542. &.openSidebar {
  543. margin-left: 210px;
  544. width: calc(100vw - 210px);
  545. }
  546. .tips {
  547. font-size: 12px;
  548. color: red;
  549. margin-top: 10px;
  550. }
  551. }
  552. </style>