add.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <div class="row">
  4. <div class="col-sm-12">
  5. <div class="ibox float-e-margins">
  6. <div class="ibox-content">
  7. <form method="post" action="{:url('add')}" class="form-horizontal">
  8. <input type="hidden" name="dep_id">
  9. <input type="hidden" name="items">
  10. <div id="dispatchapp">
  11. <div class="form-group">
  12. <label class="col-sm-2 control-label">地点<span class="text-danger">*</span></label>
  13. <div class="col-sm-6">
  14. <el-select v-model="v1" clearable filterable placeholder="请选择">
  15. <el-option
  16. v-for="item in dep"
  17. :key="item.id"
  18. :label="item.title"
  19. :value="item.id">
  20. </el-option>
  21. </el-select>
  22. </div>
  23. </div>
  24. <div class="form-group">
  25. <label class="col-sm-2 control-label">物品<span class="text-danger">*</span></label>
  26. <div class="col-sm-6">
  27. <el-select
  28. v-model="v2"
  29. multiple
  30. collapse-tags
  31. placeholder="请选择">
  32. <el-option v-for="item in items" :key="item.id" :label="item.title" :value="item.id"> </el-option>
  33. </el-select>
  34. </div>
  35. </div>
  36. <div v-if="spec.length > 0">
  37. <div class="form-group" :key="index" v-for="(item,index) in spec">
  38. <label class="col-sm-2 control-label">{{item.title}}数量<span class="text-danger">*</span></label>
  39. <div class="col-sm-6">
  40. <input type="text" @input="setValue" v-model="spec[index].num" class="form-control" >
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label class="col-sm-2 control-label">收取照片</label>
  47. <div class="col-sm-6">
  48. {:widget_view('common/upimg',['name'=>'sq_img','multi'=>0,'val'=>''])}
  49. </div>
  50. </div>
  51. <div class="form-group">
  52. <label class="col-sm-2 control-label">收取签名<span class="text-danger">*</span></label>
  53. <div class="col-sm-6">
  54. {:widget_view('common/upimg',['name'=>'sq_sign','multi'=>0,'val'=>''])}
  55. </div>
  56. </div>
  57. <div class="hr-line-dashed"></div>
  58. <div class="form-group">
  59. <div class="col-sm-6 col-sm-offset-2">
  60. <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
  61. <button class="btn cancel-btn btn-default" type="button">取 消</button>
  62. </div>
  63. </div>
  64. </form>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. {/block}
  70. {block name="script"}
  71. <script>
  72. $(document).ready(function(){
  73. formSetValue("enable", {$info.enable|default=1});
  74. formSetValue("is_show", {$info.is_show|default=0});
  75. });
  76. new Vue({
  77. el: '#dispatchapp',
  78. data: function() { // value: 'zhinan', label: '指南',children
  79. return {
  80. dep: {:json_encode($dep)},
  81. items: {:json_encode($items)},
  82. v1: '',
  83. v2: '',
  84. spec:[]
  85. }
  86. },
  87. watch: {
  88. v1: function (newQuestion, oldQuestion) {
  89. $("input[name=dep_id]").val(newQuestion);
  90. },
  91. v2: function (newQuestion, oldQuestion) {
  92. let newspec = [];
  93. newQuestion.forEach((item) => {
  94. let num = 0;
  95. let title = '';
  96. this.spec.forEach((item2) => {
  97. if(item2.id.toString() == item.toString()){
  98. num = item2.num;
  99. title = item2.title;
  100. }
  101. });
  102. if(!title){
  103. this.items.forEach((item3) => {
  104. if(item3.id.toString() == item){
  105. title = item3.title
  106. }
  107. });
  108. }
  109. newspec.push({
  110. id: item,
  111. num: num,
  112. title: title
  113. })
  114. });
  115. this.spec = JSON.parse(JSON.stringify(newspec));
  116. $("input[name=items]").val(JSON.stringify(this.spec));
  117. },
  118. },
  119. methods:{
  120. setValue:function () {
  121. console.log(this.spec);
  122. $("input[name=items]").val(JSON.stringify(this.spec));
  123. }
  124. }
  125. });
  126. </script>
  127. {/block}