AfterSales.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="after_sales">
  3. <view class="sales_info" v-if="tableList.length > 0">
  4. <view>名称:{{ fieldRow('categoryName') }}</view>
  5. <view>类型:{{ fieldRow('productCategoryName') }}</view>
  6. <view>编码:{{ fieldRow('categoryCode') }}</view>
  7. <view>发货条码:{{ fieldRow('barcodes') }}</view>
  8. <view>发货时间:{{ fieldRow('shipmentDate') }}</view>
  9. <view>质保有效期:{{ fieldRow('guaranteePeriodDeadline') }}</view>
  10. <view>计量数量:{{ fieldRow('measureQuantity') }}</view>
  11. <view class="action" v-if="type != 'view'">
  12. <text class="text">
  13. 操作:
  14. </text>
  15. <u-button @click="goProblem('add')" :plain="true" :hairline="true" size='mini' type="default"
  16. text="添加故障"></u-button>
  17. <u-button @click="del" :plain="true" :hairline="true" size='mini' type="default" class="delete"
  18. text="删除"></u-button>
  19. </view>
  20. </view>
  21. <view v-for="(item, index) in faultDetails" :key="index" style="position: relative;">
  22. <myCard @edit="goProblem('edit',index,item)" @del="delProblem(index)" :item="item" :index="index+1"
  23. :columns="columns" :btnList="btnData">
  24. </myCard>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import myCard from '@/pages/saleManage/components/myCard.vue'
  30. export default {
  31. components: {
  32. myCard
  33. },
  34. props: {
  35. itemList: {
  36. type: Array,
  37. default: () => []
  38. },
  39. type: {
  40. type: String,
  41. default: 'edit'
  42. }
  43. },
  44. watch: {
  45. itemList: {
  46. handler(newVal) {
  47. let list = JSON.parse(JSON.stringify(newVal));
  48. list.map((el) => {
  49. el.faultDetails = el.faultDetails ? el.faultDetails : []
  50. })
  51. this.tableList = list
  52. },
  53. deep: true,
  54. immediate: true
  55. }
  56. },
  57. computed: {
  58. faultDetails() {
  59. if (this.tableList.length > 0) {
  60. return this.tableList[0].faultDetails
  61. }
  62. return []
  63. },
  64. fieldRow() {
  65. return (field) => {
  66. if (this.tableList.length == 0) return '';
  67. return this.tableList[0][field]
  68. }
  69. },
  70. btnData(){
  71. if(this.type == 'view'){
  72. return []
  73. }
  74. return this.btnList;
  75. }
  76. },
  77. data() {
  78. return {
  79. typeOptions: [{
  80. text: '维修',
  81. value: '1'
  82. },
  83. {
  84. text: '保养',
  85. value: '2'
  86. },
  87. {
  88. text: '安装',
  89. value: '3'
  90. }
  91. ],
  92. columns: [
  93. [{
  94. label: '故障类型:',
  95. prop: 'type',
  96. className: 'perce100',
  97. formatter: (row) => {
  98. const user = this.typeOptions.find(item => item.value === row.type);
  99. return user.text
  100. }
  101. }],
  102. [{
  103. label: '故障现象:',
  104. prop: 'faultPhenomenon',
  105. }],
  106. [{
  107. label: '故障原因:',
  108. prop: 'faultReason'
  109. }],
  110. [{
  111. label: '维修过程:',
  112. prop: 'maintenanceProcess',
  113. className: 'perce100'
  114. }],
  115. [{
  116. label: '操作:',
  117. prop: 'action',
  118. type: this.type !='view' ? 'action' : '',
  119. className: 'perce100',
  120. }],
  121. ],
  122. btnList: [{
  123. name: '编辑',
  124. apiName: 'edit',
  125. btnType: 'error',
  126. type: '2',
  127. pageUrl: '',
  128. },
  129. {
  130. name: '删除',
  131. apiName: 'del',
  132. btnType: 'error',
  133. type: '2',
  134. pageUrl: '',
  135. }
  136. ],
  137. tableList: []
  138. }
  139. },
  140. onLoad({}) {},
  141. created() {
  142. uni.$off('updateFaultList')
  143. uni.$on('updateFaultList', ({
  144. type,
  145. data,
  146. index
  147. }) => {
  148. if (type == 'add') {
  149. this.tableList[0].faultDetails.push(data)
  150. } else {
  151. this.$set(this.tableList[0].faultDetails, index, data)
  152. }
  153. console.log(this.tableList, 'this.tableList ===')
  154. })
  155. },
  156. methods: {
  157. del() {
  158. uni.showModal({
  159. title: '确认删除',
  160. content: '确定要删除这条售后对象吗?',
  161. confirmText: '删除',
  162. confirmColor: '#FF4D4F',
  163. success: (res) => {
  164. if (res.confirm) {
  165. this.tableList = [];
  166. } else if (res.cancel) {
  167. // 用户点击了取消按钮
  168. console.log('用户取消删除');
  169. }
  170. }
  171. });
  172. },
  173. // 删除故障
  174. delProblem(index) {
  175. uni.showModal({
  176. title: '确认删除',
  177. content: '确定要删除这条故障吗?',
  178. confirmText: '删除',
  179. confirmColor: '#FF4D4F',
  180. success: (res) => {
  181. if (res.confirm) {
  182. this.tableList[0].faultDetails.splice(index, 1);
  183. } else if (res.cancel) {
  184. // 用户点击了取消按钮
  185. console.log('用户取消删除');
  186. }
  187. }
  188. });
  189. },
  190. // 现在只针对做 一 对 多 的 故障数据
  191. goProblem(type, index, obj) {
  192. let data = obj ? JSON.stringify(obj) : '';
  193. uni.navigateTo({
  194. url: `/pages/salesServiceManagement/demandList/components/faultAdd?type=${type}&index=${index}&data=${data}`
  195. })
  196. },
  197. addFault() {
  198. },
  199. getTabData() {
  200. return this.tableList || []
  201. }
  202. },
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. .sales_info {
  207. padding: 8px 16px;
  208. font-size: 13px;
  209. font-style: normal;
  210. font-weight: 400;
  211. line-height: 22px;
  212. word-wrap: break-word;
  213. border-bottom: 6rpx solid #E1E1E1;
  214. .action {
  215. display: flex;
  216. line-height: 22px;
  217. .text {
  218. margin-right: 12rpx;
  219. }
  220. /deep/ .u-button {
  221. width: 100rpx;
  222. font-size: 26rpx;
  223. margin-left: 10rpx;
  224. margin-right: 0rpx;
  225. background: #157a2c;
  226. color: #fff !important;
  227. }
  228. }
  229. }
  230. </style>