auxiliaryAdjustPriceOrderDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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="12" 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="12" v-if="id">
  18. <el-form-item label="单据编号">
  19. <el-input type="text" :value="formData.sheetId" disabled></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="6" v-if="id">
  23. <el-form-item label="制单人">
  24. <el-input type="text" :value="formData.createBy" disabled></el-input>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="6" v-if="id">
  28. <el-form-item label="制单时间">
  29. <el-input type="text" :value="formData.createTime" disabled></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="6" v-if="id">
  33. <el-form-item label="审核人">
  34. <el-input type="text" :value="formData.confirmBy" disabled></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="6" v-if="id">
  38. <el-form-item label="审核时间">
  39. <el-input type="text" :value="formData.confirmTime" disabled></el-input>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="12">
  43. <el-form-item label="所属商户" :required="true" >
  44. <el-input type="text" :value="companyName" disabled></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="12">
  48. <el-form-item label="网点名称" prop="websitId" :required="true">
  49. <el-select v-model="formData.websit" value-key="websitId" @change="changeWebsit" placeholder="请选择" style="width: 100%;">
  50. <el-option
  51. v-for="item in websitList"
  52. :key="item.websitId"
  53. :label="item.name"
  54. :value="item">
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="24">
  60. <el-form-item label="附件">
  61. <ImageUpload :fileList="formData.file_url" :limit="1" :isEdit="formType !== 2" />
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="24">
  65. <el-form-item label="备注">
  66. <el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入"></el-input>
  67. </el-form-item>
  68. </el-col>
  69. </el-row>
  70. </el-form>
  71. </div>
  72. </el-card>
  73. <el-card class="box-card">
  74. <div slot="header" class="clearfix">
  75. <span>辅材信息</span>
  76. </div>
  77. <el-button size="small" type="primary" @click="add()">添加</el-button>
  78. <div class="table">
  79. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  80. <el-table-column label="大类名称" align="center">
  81. <template slot-scope="scope">
  82. <el-select v-model="scope.row.productCategory" value-key="categoryId" @change="changeMain" :disabled="isEdit != scope.$index" placeholder="请选择" style="width: 100%;">
  83. <el-option
  84. v-for="item in mainList"
  85. :key="item.categoryId"
  86. :label="item.categoryName"
  87. :value="item">
  88. </el-option>
  89. </el-select>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="小类名称" align="center">
  93. <template slot-scope="scope">
  94. <el-select v-model="scope.row.goodsCategory" @change="changeSmall" @focus="()=>{
  95. if(!scope.row.productCategory){return this.$message.warning('请先选择大类!');}
  96. }" :disabled="isEdit != scope.$index" value-key="categoryId" placeholder="请选择" style="width: 100%;">
  97. <el-option
  98. v-for="item in scope.row.productCategory.items"
  99. :key="item.categoryId"
  100. :label="item.categoryName"
  101. :value="item">
  102. </el-option>
  103. </el-select>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="辅材名称" align="center">
  107. <template slot-scope="scope">
  108. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index" placeholder="请选择" style="width: 100%;">
  109. <el-option
  110. v-for="item in scope.row.goodsList"
  111. :key="item.goodsId"
  112. :label="item.goodsName"
  113. :value="item">
  114. </el-option>
  115. </el-select>
  116. </template>
  117. </el-table-column>
  118. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  119. <el-table-column prop="goods.goodsCode" align="center" label="商品代码"></el-table-column>
  120. <el-table-column prop="goods.goodsSpecification" align="center" label="规格型号"></el-table-column>
  121. <el-table-column prop="" align="center" label="原售价">
  122. <template slot-scope="scope">
  123. {{scope.row.goods.oldPrice || scope.row.goods.price}}
  124. </template>
  125. </el-table-column>
  126. <el-table-column prop="" align="center" label="新售价" >
  127. <template slot-scope="scope">
  128. <el-input type="number" v-model="scope.row.newPrice" :disabled="isEdit != scope.$index" placeholder="请输入"></el-input>
  129. </template>
  130. </el-table-column>
  131. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  132. <el-table-column label="操作" align="right" width="140">
  133. <template slot-scope="scope">
  134. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  135. <el-button size="mini" type="danger" @click="dataList.splice(scope.$index,1)">删除</el-button>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </div>
  140. </el-card>
  141. <div class="page-footer">
  142. <div class="footer">
  143. <el-button size="small" type="info" @click="goBack">返回</el-button>
  144. <el-button v-if="formType != 2" size="small" type="primary" @click="submit()">提交</el-button>
  145. <el-button v-if="formType == 1" size="small" type="primary" @click="confirm()">审核通过</el-button>
  146. </div>
  147. </div>
  148. </div>
  149. </template>
  150. <script>
  151. import { getWebsit } from "@/api/customerManagement";
  152. import ImageUpload from '@/components/file-upload'
  153. import { getWorker, getCategory, getGoods } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  154. import { getDetail, add, edit, confirm } from "@/api/auxiliaryFittings/auxiliaryAdjustPriceOrder";
  155. export default {
  156. components: { ImageUpload },
  157. props: ['id','title','formType'],
  158. data() {
  159. return {
  160. dataList: [],
  161. websitList: [],
  162. workerList: [],
  163. mainList: [],
  164. formData: {
  165. websit: {},
  166. websitId: '',
  167. websitName: '',
  168. file_url: [],
  169. sheetId: '',
  170. flag: '',
  171. createBy: '',
  172. createTime: '',
  173. confirmBy: '',
  174. confirmTime: '',
  175. remark: ''
  176. },
  177. productCategory: {},
  178. goodsCategory: {},
  179. isEdit: 0,
  180. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  181. rules: {
  182. websitId: [
  183. { required: true, message: '请选择网点', trigger: 'change' }
  184. ],
  185. worker: [
  186. { required: true, message: '请选择师傅', trigger: 'change' }
  187. ],
  188. source: [
  189. { required: true, message: '请选择订单来源', trigger: 'change' }
  190. ],
  191. payType: [
  192. { required: true, message: '请选择订单来源', trigger: 'change' }
  193. ],
  194. idcard: [
  195. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  196. ],
  197. phone: [
  198. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  199. ],
  200. }
  201. };
  202. },
  203. computed: {},
  204. created() {
  205. if(this.id){
  206. this.getDetail()
  207. }
  208. this.getWebsit()
  209. },
  210. mounted() {
  211. console.log(111,this.mainList)
  212. },
  213. methods: {
  214. // 返回
  215. goBack() {
  216. this.$emit('back');
  217. },
  218. async getDetail(){
  219. const that = this
  220. getDetail({sheetId: this.id}).then(res => {
  221. this.formData.flag = res.data.flag
  222. this.formData.websit = {websitId: res.data.websitId,name: res.data.websitName}
  223. this.formData.websitId = res.data.websitId
  224. this.formData.websitName = res.data.websitName
  225. this.formData.sheetId = res.data.sheetId
  226. this.formData.createBy = res.data.createBy
  227. this.formData.createTime = res.data.createTime
  228. this.formData.confirmBy = res.data.confirmBy
  229. this.formData.confirmTime = res.data.confirmTime
  230. this.getCategory(res.data.websitId)
  231. this.formData.remark = res.data.remark
  232. res.data.items.forEach(item=>{
  233. item.productCategory = {categoryId: item.parentCategoryId,categoryName: item.parentCategoryName,items: [{categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}]}
  234. item.goodsCategory = {categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}
  235. that.getGoods(item.goodsCategoryId,item.goodsName,1).then(ress => {
  236. item.goods = {...ress.data,oldPrice:ress.data.price}
  237. item.goodsList = [{...ress.data,oldPrice:ress.data.price}]
  238. })
  239. })
  240. setTimeout(()=>{
  241. this.dataList = res.data.items
  242. },200)
  243. console.log(this.dataList)
  244. })
  245. },
  246. getWebsit(){
  247. getWebsit({type: 'C'}).then(res => {
  248. this.websitList = res.data
  249. })
  250. },
  251. changeWebsit(e){
  252. this.formData.websitId = e.websitId
  253. this.formData.websitName = e.name
  254. this.getWorker()
  255. this.getCategory(e.websitId)
  256. },
  257. getCategory(websitId){
  258. getCategory({websitId}).then(res => {
  259. this.mainList = res.data
  260. })
  261. },
  262. async getGoods(categoryId,goodsName,type){
  263. const that = this
  264. if(type == 1){
  265. return new Promise((resolve, reject) => {
  266. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M',goodsName: goodsName}).then(res => {
  267. resolve({
  268. data: res.data[0]
  269. })
  270. })
  271. })
  272. }else{
  273. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M'}).then(res => {
  274. that.dataList[that.isEdit].goodsList = res.data
  275. })
  276. }
  277. },
  278. getWorker(name){
  279. const that = this
  280. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'a.nick_name',compare: '=',value: name},{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  281. if(name){
  282. that.formData.idcard = res.data.records[0].idCard
  283. that.formData.phone = res.data.records[0].mobile
  284. }else{
  285. this.workerList = res.data.records
  286. }
  287. })
  288. },
  289. changeWorker(e){
  290. this.getWorker(e)
  291. },
  292. workerBlur(e){
  293. this.formData.worker = e.target.value
  294. this.$forceUpdate()
  295. },
  296. changeMain(e){
  297. this.dataList[this.isEdit].goodsList = [],
  298. this.dataList[this.isEdit].productCategory = e,
  299. this.dataList[this.isEdit].parentCategoryId = e.categoryId,
  300. this.dataList[this.isEdit].parentCategoryName = e.categoryName,
  301. this.dataList[this.isEdit].goodsCategory = {},
  302. this.dataList[this.isEdit].goodsCategoryName = '',
  303. this.dataList[this.isEdit].goodsCategoryId = '',
  304. this.dataList[this.isEdit].goods = {},
  305. this.dataList[this.isEdit].goodsId = '',
  306. this.dataList[this.isEdit].goodsName = '',
  307. this.dataList[this.isEdit].goodsSalesUnit = '',
  308. this.dataList[this.isEdit].goodsSpecification = '',
  309. this.dataList[this.isEdit].goodsCode = '',
  310. this.dataList[this.isEdit].newPrice = '',
  311. this.dataList[this.isEdit].oldPrice = '',
  312. this.dataList[this.isEdit].qty = '',
  313. this.dataList[this.isEdit].goodsType = 'M'
  314. },
  315. async changeSmall(e){
  316. this.dataList[this.isEdit].goods = {},
  317. this.dataList[this.isEdit].goodsId = '',
  318. this.dataList[this.isEdit].goodsName = '',
  319. this.dataList[this.isEdit].goodsSalesUnit = '',
  320. this.dataList[this.isEdit].goodsSpecification = '',
  321. this.dataList[this.isEdit].goodsCode = '',
  322. this.dataList[this.isEdit].newPrice = '',
  323. this.dataList[this.isEdit].oldPrice = '',
  324. this.dataList[this.isEdit].qty = '',
  325. this.dataList[this.isEdit].goodsCategoryId = e.categoryId
  326. this.dataList[this.isEdit].goodsCategoryName = e.categoryName
  327. getGoods({websitId: this.formData.websitId,categoryId: e.categoryId,type: 'M'}).then(res => {
  328. this.dataList[this.isEdit].goodsList = res.data
  329. })
  330. },
  331. changeGoods(e){
  332. console.log(e)
  333. this.dataList[this.isEdit].goodsId = e.goodsId
  334. this.dataList[this.isEdit].goodsName = e.goodsName
  335. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  336. this.dataList[this.isEdit].goodsSpecification = e.goodsSpecification
  337. this.dataList[this.isEdit].oldPrice = e.price
  338. this.dataList[this.isEdit].goodsCode = e. goodsCode
  339. this.dataList[this.isEdit].qty = e.qty
  340. },
  341. add(){
  342. this.dataList.push({
  343. goodsList: [],
  344. productCategory: {},
  345. parentCategoryId: '',
  346. parentCategoryName: '',
  347. goodsCategory: {},
  348. goodsCategoryName: '',
  349. goodsCategoryId: '',
  350. goods: {},
  351. goodsId: '',
  352. goodsName: '',
  353. goodsSalesUnit: '',
  354. goodsSpecification: '',
  355. goodsCode: '',
  356. newPrice: '',
  357. oldPrice: '',
  358. qty: '',
  359. goodsType: 'M'
  360. })
  361. },
  362. confirm(){
  363. this.$confirm(`请确认是否审核通过, 是否继续?`, '提示', {
  364. confirmButtonText: '确定',
  365. cancelButtonText: '取消',
  366. type: 'warning'
  367. }).then(() => {
  368. confirm({
  369. sheetId: this.formData.sheetId,
  370. flag: 'OK'
  371. }).then(res => {
  372. if(res.code == 200){
  373. this.$message.success('审核成功!')
  374. this.goBack()
  375. }
  376. })
  377. });
  378. },
  379. submit(){
  380. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  381. if (valid) {
  382. if(this.formType == 0){
  383. add({
  384. remark: this.formData.remark,
  385. websitId: this.formData.websitId,
  386. websitName: this.formData.websitName,
  387. file_url: this.formData.file_url.map(item=>item.url).join(","),
  388. items: this.dataList
  389. }).then(res => {
  390. if(res.code == 200){
  391. this.$message.success('提交成功!')
  392. this.goBack()
  393. }
  394. })
  395. }else if(this.formType == 1){
  396. edit({
  397. sheetId: this.formData.sheetId,
  398. remark: this.formData.remark,
  399. websitId: this.formData.websitId,
  400. websitName: this.formData.websitName,
  401. file_url: this.formData.file_url.map(item=>item.url).join(","),
  402. items: this.dataList
  403. }).then(res => {
  404. if(res.code == 200){
  405. this.dataList = []
  406. this.$message.success('提交成功!')
  407. this.goBack()
  408. }
  409. })
  410. }
  411. }
  412. })
  413. }
  414. }
  415. };
  416. </script>
  417. <style scoped="scoped" lang="scss">
  418. .s-page {
  419. padding: 20px;
  420. background-color: #ffffff;
  421. }
  422. .page-footer {
  423. height: 70px;
  424. }
  425. .footer {
  426. position: fixed;
  427. bottom: 0;
  428. left: 0;
  429. z-index: 1;
  430. width: 100%;
  431. background: #fff;
  432. padding: 15px 40px;
  433. box-sizing: border-box;
  434. transition: all 0.28s;
  435. text-align: right;
  436. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  437. &.hideSidebar {
  438. margin-left: 54px;
  439. width: calc(100vw - 54px);
  440. }
  441. &.openSidebar {
  442. margin-left: 210px;
  443. width: calc(100vw - 210px);
  444. }
  445. .tips {
  446. font-size: 12px;
  447. color: red;
  448. margin-top: 10px;
  449. }
  450. }
  451. </style>