auxiliaryAdjustPriceOrderDetail.vue 18 KB

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