auxiliaryAdjustPriceOrderDetail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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 == 'SUBMIT'?'已提交':formData.flag == 'OK'?'审核通过':formData.flag == '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" :disabled="formData.flag == 'OK'" 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" :disabled="formData.flag == 'OK'" 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" v-if="formData.flag == 'SAVE' || formType==0" 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 || formData.flag == 'OK'" 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 || formData.flag == 'OK'" 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 || formData.flag == 'OK'" 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 || formData.flag == 'OK'" 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" v-if="formData.flag != 'OK'">
  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. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  197. ],
  198. phone: [
  199. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  200. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  201. ],
  202. }
  203. };
  204. },
  205. computed: {},
  206. created() {
  207. if(this.id){
  208. this.getDetail()
  209. }
  210. this.getWebsit()
  211. },
  212. mounted() {
  213. console.log(111,this.mainList)
  214. },
  215. methods: {
  216. // 返回
  217. goBack() {
  218. this.$emit('back');
  219. },
  220. async getDetail(){
  221. const that = this
  222. getDetail({sheetId: this.id}).then(async res => {
  223. this.formData.flag = res.data.flag
  224. this.formData.websit = {websitId: res.data.websitId,name: res.data.websitName}
  225. this.formData.websitId = res.data.websitId
  226. this.formData.websitName = res.data.websitName
  227. this.formData.sheetId = res.data.sheetId
  228. this.formData.createBy = res.data.createBy
  229. this.formData.createTime = res.data.createTime
  230. this.formData.confirmBy = res.data.confirmBy
  231. this.formData.confirmTime = res.data.confirmTime
  232. this.getCategory(res.data.websitId)
  233. this.formData.remark = res.data.remark
  234. for(var item of res.data.items){
  235. item.productCategory = {categoryId: item.parentCategoryId,categoryName: item.parentCategoryName,items: [{categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}]}
  236. item.goodsCategory = {categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}
  237. var ress = await that.getGoods(item.goodsCategoryId,item.goodsName, 1)
  238. item.goods = {...ress.data,oldPrice:ress.data.price}
  239. item.goodsList = ress.data ? [{...ress.data,oldPrice:ress.data.price}] : []
  240. }
  241. this.dataList = res.data.items
  242. })
  243. },
  244. getWebsit(){
  245. getWebsit({type: 'C'}).then(res => {
  246. this.websitList = res.data
  247. })
  248. },
  249. changeWebsit(e){
  250. this.formData.websitId = e.websitId
  251. this.formData.websitName = e.name
  252. this.getWorker()
  253. this.getCategory(e.websitId)
  254. },
  255. getCategory(websitId){
  256. getCategory({websitId}).then(res => {
  257. this.mainList = res.data
  258. })
  259. },
  260. async getGoods(categoryId,goodsName,type){
  261. const that = this
  262. if(type == 1){
  263. return new Promise((resolve, reject) => {
  264. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M',goodsName: goodsName}).then(res => {
  265. resolve({
  266. data: res.data[0]
  267. })
  268. })
  269. })
  270. }else{
  271. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M'}).then(res => {
  272. that.dataList[that.isEdit].goodsList = res.data
  273. })
  274. }
  275. },
  276. getWorker(name){
  277. const that = this
  278. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'a.nick_name',compare: '=',value: name},{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  279. if(name){
  280. that.formData.idcard = res.data.records[0].idCard
  281. that.formData.phone = res.data.records[0].mobile
  282. }else{
  283. this.workerList = res.data.records
  284. }
  285. })
  286. },
  287. changeWorker(e){
  288. this.getWorker(e)
  289. },
  290. workerBlur(e){
  291. this.formData.worker = e.target.value
  292. this.$forceUpdate()
  293. },
  294. changeMain(e){
  295. this.dataList[this.isEdit].goodsList = [],
  296. this.dataList[this.isEdit].productCategory = e,
  297. this.dataList[this.isEdit].parentCategoryId = e.categoryId,
  298. this.dataList[this.isEdit].parentCategoryName = e.categoryName,
  299. this.dataList[this.isEdit].goodsCategory = {},
  300. this.dataList[this.isEdit].goodsCategoryName = '',
  301. this.dataList[this.isEdit].goodsCategoryId = '',
  302. this.dataList[this.isEdit].goods = {},
  303. this.dataList[this.isEdit].goodsId = '',
  304. this.dataList[this.isEdit].goodsName = '',
  305. this.dataList[this.isEdit].goodsSalesUnit = '',
  306. this.dataList[this.isEdit].goodsSpecification = '',
  307. this.dataList[this.isEdit].goodsCode = '',
  308. this.dataList[this.isEdit].newPrice = '',
  309. this.dataList[this.isEdit].oldPrice = '',
  310. this.dataList[this.isEdit].qty = '',
  311. this.dataList[this.isEdit].goodsType = 'M'
  312. },
  313. async changeSmall(e){
  314. this.dataList[this.isEdit].goods = {},
  315. this.dataList[this.isEdit].goodsId = '',
  316. this.dataList[this.isEdit].goodsName = '',
  317. this.dataList[this.isEdit].goodsSalesUnit = '',
  318. this.dataList[this.isEdit].goodsSpecification = '',
  319. this.dataList[this.isEdit].goodsCode = '',
  320. this.dataList[this.isEdit].newPrice = '',
  321. this.dataList[this.isEdit].oldPrice = '',
  322. this.dataList[this.isEdit].qty = '',
  323. this.dataList[this.isEdit].goodsCategoryId = e.categoryId
  324. this.dataList[this.isEdit].goodsCategoryName = e.categoryName
  325. getGoods({websitId: this.formData.websitId,categoryId: e.categoryId,type: 'M'}).then(res => {
  326. this.dataList[this.isEdit].goodsList = res.data
  327. })
  328. },
  329. changeGoods(e){
  330. console.log(e)
  331. this.dataList[this.isEdit].goodsId = e.goodsId
  332. this.dataList[this.isEdit].goodsName = e.goodsName
  333. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  334. this.dataList[this.isEdit].goodsSpecification = e.goodsSpecification
  335. this.dataList[this.isEdit].oldPrice = e.price
  336. this.dataList[this.isEdit].goodsCode = e. goodsCode
  337. this.dataList[this.isEdit].qty = e.qty
  338. },
  339. add(){
  340. if(this.dataList.length != 0){this.isEdit += 1}
  341. this.dataList.push({
  342. goodsList: [],
  343. productCategory: {},
  344. parentCategoryId: '',
  345. parentCategoryName: '',
  346. goodsCategory: {},
  347. goodsCategoryName: '',
  348. goodsCategoryId: '',
  349. goods: {},
  350. goodsId: '',
  351. goodsName: '',
  352. goodsSalesUnit: '',
  353. goodsSpecification: '',
  354. goodsCode: '',
  355. newPrice: '',
  356. oldPrice: '',
  357. qty: '',
  358. goodsType: 'M'
  359. })
  360. },
  361. confirm(){
  362. this.$confirm(`请确认是否审核通过, 是否继续?`, '提示', {
  363. confirmButtonText: '确定',
  364. cancelButtonText: '取消',
  365. type: 'warning'
  366. }).then(() => {
  367. confirm({
  368. sheetId: this.formData.sheetId,
  369. flag: 'OK'
  370. }).then(res => {
  371. if(res.code == 200){
  372. this.$message.success('审核成功!')
  373. this.goBack()
  374. }
  375. })
  376. });
  377. },
  378. submit(){
  379. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  380. if (valid) {
  381. if(this.formType == 0){
  382. add({
  383. remark: this.formData.remark,
  384. websitId: this.formData.websitId,
  385. websitName: this.formData.websitName,
  386. file_url: this.formData.file_url.map(item=>item.url).join(","),
  387. items: this.dataList
  388. }).then(res => {
  389. if(res.code == 200){
  390. this.$message.success('提交成功!')
  391. this.goBack()
  392. }
  393. })
  394. }else if(this.formType == 1){
  395. edit({
  396. sheetId: this.formData.sheetId,
  397. remark: this.formData.remark,
  398. websitId: this.formData.websitId,
  399. websitName: this.formData.websitName,
  400. file_url: this.formData.file_url.map(item=>item.url).join(","),
  401. items: this.dataList
  402. }).then(res => {
  403. if(res.code == 200){
  404. this.dataList = []
  405. this.$message.success('提交成功!')
  406. this.goBack()
  407. }
  408. })
  409. }
  410. }
  411. })
  412. }
  413. }
  414. };
  415. </script>
  416. <style scoped="scoped" lang="scss">
  417. .s-page {
  418. padding: 20px;
  419. background-color: #ffffff;
  420. }
  421. .page-footer {
  422. height: 70px;
  423. }
  424. .footer {
  425. position: fixed;
  426. bottom: 0;
  427. left: 0;
  428. z-index: 1;
  429. width: 100%;
  430. background: #fff;
  431. padding: 15px 40px;
  432. box-sizing: border-box;
  433. transition: all 0.28s;
  434. text-align: right;
  435. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  436. &.hideSidebar {
  437. margin-left: 54px;
  438. width: calc(100vw - 54px);
  439. }
  440. &.openSidebar {
  441. margin-left: 210px;
  442. width: calc(100vw - 210px);
  443. }
  444. .tips {
  445. font-size: 12px;
  446. color: red;
  447. margin-top: 10px;
  448. }
  449. }
  450. </style>