schemeList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="scheme">
  3. <u-list class="listContent">
  4. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  5. <myCard :item="item" @del="del(index)" @edit="add('edit',item,index)" :index="index+1"
  6. :columns="columns" :btnList="btnData">
  7. </myCard>
  8. </view>
  9. </u-list>
  10. <view class="add" @click="add('add')" v-if="type != 'view'">
  11. <u-icon name="plus" color="#fff"></u-icon>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import myCard from '@/pages/saleManage/components/myCard.vue'
  17. import {
  18. getWarehouseOutStock,
  19. getIdWarehouseList
  20. } from '@/api/salesServiceManagement/workOrder/index.js';
  21. import {
  22. getByCode
  23. } from '@/api/pda/common.js'
  24. export default {
  25. components: {
  26. myCard
  27. },
  28. props: {
  29. type: {
  30. type: String,
  31. default: 'edit'
  32. },
  33. itemList: {
  34. type: Array,
  35. default: () => []
  36. },
  37. pageName: ''
  38. },
  39. watch: {
  40. itemList: {
  41. handler(newVal) {
  42. let list = JSON.parse(JSON.stringify(newVal));
  43. this.tableList = list;
  44. this.setTabData()
  45. },
  46. deep: true,
  47. immediate: true
  48. }
  49. },
  50. data() {
  51. return {
  52. typeIdList: [],
  53. btnList: [{
  54. name: '修改',
  55. apiName: 'edit',
  56. btnType: 'primary',
  57. type: '2',
  58. pageUrl: '',
  59. judge: [{
  60. authorities: '',
  61. }, {
  62. fn: (row) => {
  63. return (this.type != 'view' &&
  64. row.isApply != 1
  65. );
  66. }
  67. }]
  68. },
  69. {
  70. name: '删除',
  71. apiName: 'del',
  72. btnType: 'primary',
  73. type: '2',
  74. pageUrl: '',
  75. judge: [{
  76. authorities: '',
  77. }, {
  78. fn: (row) => {
  79. return (this.type != 'view' &&
  80. row.isApply != 1
  81. );
  82. },
  83. }]
  84. },
  85. ],
  86. tableList: []
  87. }
  88. },
  89. computed: {
  90. btnData() {
  91. if (this.type == 'view') {
  92. return [];
  93. }
  94. return this.btnList;
  95. },
  96. columns() {
  97. return [
  98. [{
  99. label: '名称:',
  100. prop: 'name',
  101. type: 'title',
  102. className: 'perce100',
  103. }],
  104. [{
  105. label: '项目:',
  106. prop: 'typeId',
  107. formatter: (row) => {
  108. let typeId = row.typeId;
  109. return this.typeIdList.find(item => item.value == typeId)?.text
  110. }
  111. }],
  112. [{
  113. label: '编码:',
  114. prop: 'code'
  115. }, ],
  116. [{
  117. label: '型号:',
  118. prop: 'categoryModel'
  119. }, {
  120. label: '规格:',
  121. prop: 'specification',
  122. }],
  123. [{
  124. label: '仓库:',
  125. prop: 'warehouseName'
  126. }],
  127. [{
  128. label: '库存:',
  129. prop: 'warehouseNum',
  130. }, {
  131. label: '单位:',
  132. prop: 'measureUnit'
  133. }],
  134. [{
  135. label: '数量:',
  136. prop: 'totalCount',
  137. }, {
  138. label: '单价:',
  139. prop: 'singlePrice'
  140. }],
  141. [{
  142. label: '合计:',
  143. prop: 'settlementPrice',
  144. }],
  145. [{
  146. label: '详细内容:',
  147. prop: 'content'
  148. }],
  149. [{
  150. prop: 'sparePartsApplyApprovalStatus',
  151. label: '审核状态:',
  152. isNone: this.pageName != 'workOrder',
  153. formatter: (row) => {
  154. if (row.typeId == 2) {
  155. const reviewStatus = {
  156. 0: '未提交',
  157. 1: '审核中',
  158. 2: '已审核',
  159. 3: '审核不通过'
  160. }
  161. return !row.sparePartsApplyApprovalStatus ?
  162. '未提交' :
  163. reviewStatus[row.sparePartsApplyApprovalStatus];
  164. }
  165. },
  166. },
  167. {
  168. prop: 'sparePartsApplyApprovalStatus',
  169. isNone: this.pageName != 'workOrder',
  170. label: '出库状态:',
  171. formatter: (row) => {
  172. if (row.typeId == 2) {
  173. return row.sparePartsApplyApprovalStatus == 2 ?
  174. '已出库' :
  175. '未出库';
  176. }
  177. },
  178. }
  179. ],
  180. [{
  181. label: '操作:',
  182. prop: 'action',
  183. type: 'action',
  184. className: 'perce100',
  185. }],
  186. ]
  187. }
  188. },
  189. created() {
  190. this.getLevelCode('after_sales_project')
  191. uni.$off('updateInfo');
  192. uni.$on('updateInfo', (data) => {
  193. if (data.index || data.index == 0) {
  194. let index = data.index;
  195. delete data.index;
  196. this.$set(this.tableList, index, data);
  197. return
  198. }
  199. this.tableList.push(data);
  200. })
  201. },
  202. onShow() {
  203. },
  204. methods: {
  205. getTotalPrice(){
  206. return this.tableList.reduce((a,b)=>{
  207. console.log(b,'b.settlementPrice')
  208. return a+(Number(b.settlementPrice)||0)
  209. },0)
  210. },
  211. async getLevelCode(code) {
  212. try {
  213. const res = await getByCode(code);
  214. if (res) {
  215. let list = Object.values(res).map((el) => {
  216. let k = Object.keys(el)[0];
  217. let v = Object.values(el)[0];
  218. return {
  219. text: v,
  220. value: k
  221. };
  222. });
  223. this.typeIdList = list;
  224. }
  225. } catch (err) {
  226. }
  227. },
  228. add(type, item = {}, index) {
  229. if (type == 'edit') {
  230. item.index = index;
  231. }
  232. let data = JSON.stringify(item);
  233. uni.navigateTo({
  234. url: `/pages/salesServiceManagement/workOrder/components/schemeAdd?obtain=仓库&type=${type}&data=${data}`
  235. })
  236. },
  237. del(index) {
  238. uni.showModal({
  239. title: '确认删除',
  240. content: '确定要删除所选方案数据吗?',
  241. confirmText: '删除',
  242. confirmColor: '#FF4D4F',
  243. success: (res) => {
  244. if (res.confirm) {
  245. this.tableList.splice(index, 1)
  246. } else if (res.cancel) {
  247. // 用户点击了取消按钮
  248. console.log('用户取消删除');
  249. }
  250. }
  251. });
  252. },
  253. async setTabData() {
  254. this.tableList.forEach(async (item, index) => {
  255. if (item.typeId == 2) {
  256. this.$set(
  257. this.tableList[index],
  258. 'warehouseList',
  259. await getIdWarehouseList({
  260. categoryId: item.categoryId
  261. })
  262. );
  263. if (item.warehouseId) {
  264. this.$set(
  265. this.tableList[index],
  266. 'warehouseNum',
  267. await getWarehouseOutStock({
  268. warehouseId: item.warehouseId,
  269. code: item.code
  270. })
  271. );
  272. }
  273. }
  274. });
  275. },
  276. getTabData() {
  277. return this.tableList || []
  278. }
  279. }
  280. }
  281. </script>
  282. <style lang="scss" scoped>
  283. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  284. .scheme {
  285. padding: 10rpx 20rpx 84rpx;
  286. }
  287. .add {
  288. width: 96rpx;
  289. height: 96rpx;
  290. border-radius: 48rpx;
  291. background: #3c9cff;
  292. position: fixed;
  293. bottom: 100rpx;
  294. right: 24rpx;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. }
  299. </style>