auxiliaryAdjustPriceOrderDetail.vue 18 KB

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