AfterSales.vue 5.0 KB

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